From c3aaee291701ada872f6c8b6ef0255085d77bf78 Mon Sep 17 00:00:00 2001 From: krishna <vamsi.sirigirisetty@pal.tech> Date: Wed, 13 Nov 2024 15:40:50 +0530 Subject: [PATCH 1/9] implemented exceptionfunctionality --- .../Controllers/ChallengeController.cs | 2 +- FoodTracker.Api/Controllers/FoodController.cs | 5 - FoodTracker.Api/Program.cs | 21 +- FoodTracker.Api/food_items.json | 462 ------------------ 4 files changed, 2 insertions(+), 488 deletions(-) delete mode 100644 FoodTracker.Api/food_items.json diff --git a/FoodTracker.Api/Controllers/ChallengeController.cs b/FoodTracker.Api/Controllers/ChallengeController.cs index 525f461..fb8ae9b 100644 --- a/FoodTracker.Api/Controllers/ChallengeController.cs +++ b/FoodTracker.Api/Controllers/ChallengeController.cs @@ -31,7 +31,7 @@ namespace FoodTracker.Api.Controllers } [TypeFilter(typeof(AuthorizationFilter), Arguments = new object[] {"User"})] - [HttpPost] + [HttpPost("viewLeaderboard")] public async Task<IActionResult> ViewLeaderboard([FromForm]int challengeId){ return Ok(await _groupChallenge.GetChallengeLeaderboard(challenegeId:challengeId)); } diff --git a/FoodTracker.Api/Controllers/FoodController.cs b/FoodTracker.Api/Controllers/FoodController.cs index 82f4fd0..7b7e951 100644 --- a/FoodTracker.Api/Controllers/FoodController.cs +++ b/FoodTracker.Api/Controllers/FoodController.cs @@ -22,14 +22,9 @@ namespace FoodTracker.Api.Controllers } [TypeFilter(typeof(AuthorizationFilter), Arguments = new object[] { "User" })] [HttpPost("addFood/other")] -<<<<<<< HEAD public async Task<IActionResult> AddFoodItem([FromForm] FoodCustomEntryDTO foodEntry) { await _foodServices.AddFoodEntry(foodEntry, _loggedInUser.Id); -======= - public async Task<IActionResult> AddFoodItem([FromForm]FoodCustomEntryDTO foodEntry){ - await _foodServices.AddFoodEntry(foodEntry,_loggedInUser.Id); ->>>>>>> main return Ok(foodEntry); } [TypeFilter(typeof(AuthorizationFilter), Arguments = new object[] { "User" })] diff --git a/FoodTracker.Api/Program.cs b/FoodTracker.Api/Program.cs index 2aaf1e4..108aa40 100644 --- a/FoodTracker.Api/Program.cs +++ b/FoodTracker.Api/Program.cs @@ -6,32 +6,13 @@ using FoodTracker.Services.Interface; using FoodTracker.Services.Implementation; using FoodTracker.Database.Interface; using FoodTracker.Database.Implementation; - using System.Text.Json.Serialization; using FoodTracker.Utilites; -using FoodTracker.Database.Entity; using FoodTracker.Api.Middleware; -using Microsoft.Data.SqlClient; var builder = WebApplication.CreateBuilder(args); -//string connectionString ="Server=PTDELL0257;Database=FoodTrackerDb;User Id=sa;Password=Welcome@1234;TrustServerCertificate=True;Encrypt=False;"; - -// // Test the connection to the database -// using (var connection = new SqlConnection(connectionString)) -// { -// try -// { -// connection.Open(); -// Console.WriteLine("Connection to SQL Server successful!"); -// } -// catch (SqlException ex) -// { -// Console.WriteLine($"Connection to SQL Server failed: {ex.Message}"); -// } -// } - builder.Services.AddDbContext<ApplicationDbContext>(options => options.UseSqlServer(builder.Configuration.GetSection("ConnectionStrings")["DefaultConnection"]) ); @@ -58,7 +39,7 @@ builder.Services.AddScoped<IChallengeRepo,GroupChallengeManager>(); builder.Services.AddScoped<IActivityService, ActivityService>(); builder.Services.AddScoped<IActivityRepo, Activitytracking>(); builder.Services.AddSingleton<LoggedInUser>(); -builder.Services.AddSingleton<SmsSender>(); +//builder.Services.AddSingleton<SmsSender>(); // builder.Services.AddTransient<IActivityRepo,ActivityTracking>(); var app = builder.Build(); diff --git a/FoodTracker.Api/food_items.json b/FoodTracker.Api/food_items.json deleted file mode 100644 index 12723be..0000000 --- a/FoodTracker.Api/food_items.json +++ /dev/null @@ -1,462 +0,0 @@ -[ - { - "name": "Basmati Rice", - "category": "Grain", - "calories": 130, - "protein": 2.7, - "fat": 0.3, - "portionsize": 100, - "sugars": 0.1, - "potassium": 26 - }, - { - "name": "Chapati", - "category": "Grain", - "calories": 120, - "protein": 3.5, - "fat": 0.5, - "portionsize": 100, - "sugars": 0.5, - "potassium": 100 - }, - { - "name": "Dal (Lentils)", - "category": "Legume", - "calories": 116, - "protein": 9, - "fat": 0.4, - "portionsize": 100, - "sugars": 0.6, - "potassium": 400 - }, - { - "name": "Paneer", - "category": "Dairy", - "calories": 265, - "protein": 18, - "fat": 20, - "portionsize": 100, - "sugars": 0.8, - "potassium": 150 - }, - { - "name": "Chicken Curry", - "category": "Meat", - "calories": 200, - "protein": 25, - "fat": 10, - "portionsize": 100, - "sugars": 1.0, - "potassium": 300 - }, - { - "name": "Fish Curry", - "category": "Fish", - "calories": 250, - "protein": 22, - "fat": 15, - "portionsize": 100, - "sugars": 0.5, - "potassium": 350 - }, - { - "name": "Palak Paneer", - "category": "Vegetable", - "calories": 220, - "protein": 12, - "fat": 15, - "portionsize": 100, - "sugars": 1.2, - "potassium": 450 - }, - { - "name": "Aloo Gobi", - "category": "Vegetable", - "calories": 80, - "protein": 2, - "fat": 3, - "portionsize": 100, - "sugars": 1.0, - "potassium": 300 - }, - { - "name": "Samosa", - "category": "Snack", - "calories": 250, - "protein": 5, - "fat": 12, - "portionsize": 100, - "sugars": 2.5, - "potassium": 200 - }, - { - "name": "Chole (Chickpeas)", - "category": "Legume", - "calories": 164, - "protein": 8.9, - "fat": 2.6, - "portionsize": 100, - "sugars": 1.0, - "potassium": 450 - }, - { - "name": "Dhokla", - "category": "Snack", - "calories": 120, - "protein": 6, - "fat": 2, - "portionsize": 100, - "sugars": 1.5, - "potassium": 150 - }, - { - "name": "Raita", - "category": "Dairy", - "calories": 50, - "protein": 3, - "fat": 2, - "portionsize": 100, - "sugars": 1.0, - "potassium": 100 - }, - { - "name": "Pav Bhaji", - "category": "Snack", - "calories": 200, - "protein": 6, - "fat": 8, - "portionsize": 100, - "sugars": 2.0, - "potassium": 250 - }, - { - "name": "Biryani", - "category": "Grain", - "calories": 250, - "protein": 10, - "fat": 10, - "portionsize": 100, - "sugars": 1.5, - "potassium": 300 - }, - { - "name": "Masoor Dal", - "category": "Legume", - "calories": 116, - "protein": 9, - "fat": 0.4, - "portionsize": 100, - "sugars": 0.5, - "potassium": 400 - }, - { - "name": "Vegetable Pulao", - "category": "Grain", - "calories": 150, - "protein": 3, - "fat": 5, - "portionsize": 100, - "sugars": 1.0, - "potassium": 250 - }, - { - "name": "Tandoori Chicken", - "category": "Meat", - "calories": 250, - "protein": 30, - "fat": 12, - "portionsize": 100, - "sugars": 0.5, - "potassium": 300 - }, - { - "name": "Pani Puri", - "category": "Snack", - "calories": 200, - "protein": 3, - "fat": 8, - "portionsize": 100, - "sugars": 1.5, - "potassium": 200 - }, - { - "name": "Kheer", - "category": "Dessert", - "calories": 120, - "protein": 3, - "fat": 4, - "portionsize": 100, - "sugars": 2.0, - "potassium": 150 - }, - { - "name": "Lassi", - "category": "Dairy", - "calories": 90, - "protein": 3, - "fat": 3, - "portionsize": 100, - "sugars": 4.0, - "potassium": 100 - }, - { - "name": "Pongal", - "category": "Grain", - "calories": 150, - "protein": 4, - "fat": 5, - "portionsize": 100, - "sugars": 1.0, - "potassium": 200 - }, - { - "name": "Idli", - "category": "Grain", - "calories": 100, - "protein": 2, - "fat": 0.5, - "portionsize": 100, - "sugars": 0.5, - "potassium": 150 - }, - { - "name": "Dosa", - "category": "Grain", - "calories": 150, - "protein": 3, - "fat": 5, - "portionsize": 100, - "sugars": 1.0, - "potassium": 200 - }, - { - "name": "Apple", - "category": "Fruit", - "calories": 52, - "protein": 0.3, - "fat": 0.2, - "portionsize": 100, - "sugars": 10.4, - "potassium": 107 - }, - { - "name": "Banana", - "category": "Fruit", - "calories": 89, - "protein": 1.1, - "fat": 0.3, - "portionsize": 100, - "sugars": 12.2, - "potassium": 358 - }, - { - "name": "Orange", - "category": "Fruit", - "calories": 47, - "protein": 0.9, - "fat": 0.1, - "portionsize": 100, - "sugars": 9.4, - "potassium": 181 - }, - { - "name": "Strawberry", - "category": "Fruit", - "calories": 32, - "protein": 0.7, - "fat": 0.3, - "portionsize": 100, - "sugars": 4.9, - "potassium": 153 - }, - { - "name": "Grapes", - "category": "Fruit", - "calories": 69, - "protein": 0.7, - "fat": 0.2, - "portionsize": 100, - "sugars": 15.5, - "potassium": 191 - }, - { - "name": "Blueberries", - "category": "Fruit", - "calories": 57, - "protein": 0.7, - "fat": 0.3, - "portionsize": 100, - "sugars": 9.7, - "potassium": 77 - }, - { - "name": "Mango", - "category": "Fruit", - "calories": 60, - "protein": 0.8, - "fat": 0.4, - "portionsize": 100, - "sugars": 14.8, - "potassium": 168 - }, - { - "name": "Pineapple", - "category": "Fruit", - "calories": 50, - "protein": 0.5, - "fat": 0.1, - "portionsize": 100, - "sugars": 9.9, - "potassium": 109 - }, - { - "name": "Carrot", - "category": "Vegetable", - "calories": 41, - "protein": 0.9, - "fat": 0.2, - "portionsize": 100, - "sugars": 4.7, - "potassium": 320 - }, - { - "name": "Broccoli", - "category": "Vegetable", - "calories": 34, - "protein": 2.8, - "fat": 0.4, - "portionsize": 100, - "sugars": 1.7, - "potassium": 316 - }, - { - "name": "Spinach", - "category": "Vegetable", - "calories": 23, - "protein": 2.9, - "fat": 0.4, - "portionsize": 100, - "sugars": 0.4, - "potassium": 558 - }, - { - "name": "Chicken Breast", - "category": "Meat", - "calories": 165, - "protein": 31, - "fat": 3.6, - "portionsize": 100, - "sugars": 0.0, - "potassium": 256 - }, - { - "name": "Salmon", - "category": "Fish", - "calories": 206, - "protein": 22, - "fat": 13, - "portionsize": 100, - "sugars": 0.0, - "potassium": 628 - }, - { - "name": "Brown Rice", - "category": "Grain", - "calories": 111, - "protein": 2.6, - "fat": 0.9, - "portionsize": 100, - "sugars": 0.4, - "potassium": 86 - }, - { - "name": "Quinoa", - "category": "Grain", - "calories": 120, - "protein": 4.1, - "fat": 1.9, - "portionsize": 100, - "sugars": 0.9, - "potassium": 318 - }, - { - "name": "Almonds", - "category": "Nuts", - "calories": 576, - "protein": 21, - "fat": 50, - "portionsize": 100, - "sugars": 4.4, - "potassium": 705 - }, - { - "name": "Walnuts", - "category": "Nuts", - "calories": 654, - "protein": 15, - "fat": 65, - "portionsize": 100, - "sugars": 2.6, - "potassium": 441 - }, - { - "name": "Greek Yogurt", - "category": "Dairy", - "calories": 59, - "protein": 10, - "fat": 0.4, - "portionsize": 100, - "sugars": 3.6, - "potassium": 141 - }, - { - "name": "Oats", - "category": "Grain", - "calories": 389, - "protein": 16.9, - "fat": 6.9, - "portionsize": 100, - "sugars": 0.9, - "potassium": 429 - }, - { - "name": "Egg", - "category": "Protein", - "calories": 155, - "protein": 13, - "fat": 11, - "portionsize": 100, - "sugars": 0.7, - "potassium": 126 - }, - { - "name": "Cottage Cheese", - "category": "Dairy", - "calories": 98, - "protein": 11, - "fat": 4.3, - "portionsize": 100, - "sugars": 3.0, - "potassium": 104 - }, - { - "name": "Sweet Potato", - "category": "Vegetable", - "calories": 86, - "protein": 1.6, - "fat": 0.1, - "portionsize": 100, - "sugars": 4.2, - "potassium": 337 - }, - { - "name": "Zucchini", - "category": "Vegetable", - "calories": 17, - "protein": 1.2, - "fat": 0.3, - "portionsize": 100, - "sugars": 2.0, - "potassium": 261 - } -] \ No newline at end of file -- GitLab From 661efcbfb3fa0eec0ab032ae74d6499849d7bd92 Mon Sep 17 00:00:00 2001 From: krishna <vamsi.sirigirisetty@pal.tech> Date: Wed, 13 Nov 2024 17:24:44 +0530 Subject: [PATCH 2/9] modified activitytracking --- .../FoodTracker.Database.csproj | 2 + .../Implementation/Activitytracking.cs | 25 +- FoodTracker.Database/food_items.json | 462 ++++++++++++++++++ 3 files changed, 476 insertions(+), 13 deletions(-) create mode 100644 FoodTracker.Database/food_items.json diff --git a/FoodTracker.Database/FoodTracker.Database.csproj b/FoodTracker.Database/FoodTracker.Database.csproj index d9c970e..83c72a8 100644 --- a/FoodTracker.Database/FoodTracker.Database.csproj +++ b/FoodTracker.Database/FoodTracker.Database.csproj @@ -25,4 +25,6 @@ <ProjectReference Include="..\FoodTracker.Utilites\FoodTracker.Utilites.csproj" /> </ItemGroup> + + </Project> diff --git a/FoodTracker.Database/Implementation/Activitytracking.cs b/FoodTracker.Database/Implementation/Activitytracking.cs index 57c0a12..00f99d9 100644 --- a/FoodTracker.Database/Implementation/Activitytracking.cs +++ b/FoodTracker.Database/Implementation/Activitytracking.cs @@ -19,10 +19,9 @@ public class Activitytracking : IActivityRepo { try { - var userActivity = _context.UserActivity.Where(user=>user.UserId==_loggedInUser.Id).FirstOrDefault(date=>date.DateTime.Date==DateTime.Now.Date); + var userActivity = _context.UserActivity.Where(user=>user.UserId==_loggedInUser.Id).Where(activity=>activity.IsAvailable==true).FirstOrDefault(date=>date.DateTime.Date==DateTime.Now.Date); if(userActivity==null){ var result = await _context.UserActivity.AddAsync(activityLog); - await _context.SaveChangesAsync(); return true; } @@ -30,8 +29,7 @@ public class Activitytracking : IActivityRepo } catch (Exception ex) { - System.Console.WriteLine(ex.Message); - return false; + throw new Exception(ex.Message); } @@ -50,21 +48,23 @@ public class Activitytracking : IActivityRepo } catch (Exception ex) { - // System.Console.WriteLine(ex.Message); - throw; - // return false; + + throw new Exception(ex.Message); + } } public ActivityTracking Read(int userId) { try{ - var activityList = _context.UserActivity.Where(user=>user.UserId==userId).FirstOrDefault(user=>user.DateTime.Date==DateTime.Now.Date); + var activityList = _context.UserActivity.Where(user=>user.UserId==userId).Where(u=>u.IsAvailable==true).FirstOrDefault(user=>user.DateTime.Date==DateTime.Now.Date); + if(activityList==null){ + return new ActivityTracking(); + } return activityList; } catch (Exception ex) { - throw; - // System.Console.WriteLine(ex.Message); - + throw new Exception(ex.Message); + } } @@ -78,8 +78,7 @@ public class Activitytracking : IActivityRepo } catch (Exception ex) { - System.Console.WriteLine(ex.Message); - return false; + throw new Exception(ex.Message); } } diff --git a/FoodTracker.Database/food_items.json b/FoodTracker.Database/food_items.json new file mode 100644 index 0000000..12723be --- /dev/null +++ b/FoodTracker.Database/food_items.json @@ -0,0 +1,462 @@ +[ + { + "name": "Basmati Rice", + "category": "Grain", + "calories": 130, + "protein": 2.7, + "fat": 0.3, + "portionsize": 100, + "sugars": 0.1, + "potassium": 26 + }, + { + "name": "Chapati", + "category": "Grain", + "calories": 120, + "protein": 3.5, + "fat": 0.5, + "portionsize": 100, + "sugars": 0.5, + "potassium": 100 + }, + { + "name": "Dal (Lentils)", + "category": "Legume", + "calories": 116, + "protein": 9, + "fat": 0.4, + "portionsize": 100, + "sugars": 0.6, + "potassium": 400 + }, + { + "name": "Paneer", + "category": "Dairy", + "calories": 265, + "protein": 18, + "fat": 20, + "portionsize": 100, + "sugars": 0.8, + "potassium": 150 + }, + { + "name": "Chicken Curry", + "category": "Meat", + "calories": 200, + "protein": 25, + "fat": 10, + "portionsize": 100, + "sugars": 1.0, + "potassium": 300 + }, + { + "name": "Fish Curry", + "category": "Fish", + "calories": 250, + "protein": 22, + "fat": 15, + "portionsize": 100, + "sugars": 0.5, + "potassium": 350 + }, + { + "name": "Palak Paneer", + "category": "Vegetable", + "calories": 220, + "protein": 12, + "fat": 15, + "portionsize": 100, + "sugars": 1.2, + "potassium": 450 + }, + { + "name": "Aloo Gobi", + "category": "Vegetable", + "calories": 80, + "protein": 2, + "fat": 3, + "portionsize": 100, + "sugars": 1.0, + "potassium": 300 + }, + { + "name": "Samosa", + "category": "Snack", + "calories": 250, + "protein": 5, + "fat": 12, + "portionsize": 100, + "sugars": 2.5, + "potassium": 200 + }, + { + "name": "Chole (Chickpeas)", + "category": "Legume", + "calories": 164, + "protein": 8.9, + "fat": 2.6, + "portionsize": 100, + "sugars": 1.0, + "potassium": 450 + }, + { + "name": "Dhokla", + "category": "Snack", + "calories": 120, + "protein": 6, + "fat": 2, + "portionsize": 100, + "sugars": 1.5, + "potassium": 150 + }, + { + "name": "Raita", + "category": "Dairy", + "calories": 50, + "protein": 3, + "fat": 2, + "portionsize": 100, + "sugars": 1.0, + "potassium": 100 + }, + { + "name": "Pav Bhaji", + "category": "Snack", + "calories": 200, + "protein": 6, + "fat": 8, + "portionsize": 100, + "sugars": 2.0, + "potassium": 250 + }, + { + "name": "Biryani", + "category": "Grain", + "calories": 250, + "protein": 10, + "fat": 10, + "portionsize": 100, + "sugars": 1.5, + "potassium": 300 + }, + { + "name": "Masoor Dal", + "category": "Legume", + "calories": 116, + "protein": 9, + "fat": 0.4, + "portionsize": 100, + "sugars": 0.5, + "potassium": 400 + }, + { + "name": "Vegetable Pulao", + "category": "Grain", + "calories": 150, + "protein": 3, + "fat": 5, + "portionsize": 100, + "sugars": 1.0, + "potassium": 250 + }, + { + "name": "Tandoori Chicken", + "category": "Meat", + "calories": 250, + "protein": 30, + "fat": 12, + "portionsize": 100, + "sugars": 0.5, + "potassium": 300 + }, + { + "name": "Pani Puri", + "category": "Snack", + "calories": 200, + "protein": 3, + "fat": 8, + "portionsize": 100, + "sugars": 1.5, + "potassium": 200 + }, + { + "name": "Kheer", + "category": "Dessert", + "calories": 120, + "protein": 3, + "fat": 4, + "portionsize": 100, + "sugars": 2.0, + "potassium": 150 + }, + { + "name": "Lassi", + "category": "Dairy", + "calories": 90, + "protein": 3, + "fat": 3, + "portionsize": 100, + "sugars": 4.0, + "potassium": 100 + }, + { + "name": "Pongal", + "category": "Grain", + "calories": 150, + "protein": 4, + "fat": 5, + "portionsize": 100, + "sugars": 1.0, + "potassium": 200 + }, + { + "name": "Idli", + "category": "Grain", + "calories": 100, + "protein": 2, + "fat": 0.5, + "portionsize": 100, + "sugars": 0.5, + "potassium": 150 + }, + { + "name": "Dosa", + "category": "Grain", + "calories": 150, + "protein": 3, + "fat": 5, + "portionsize": 100, + "sugars": 1.0, + "potassium": 200 + }, + { + "name": "Apple", + "category": "Fruit", + "calories": 52, + "protein": 0.3, + "fat": 0.2, + "portionsize": 100, + "sugars": 10.4, + "potassium": 107 + }, + { + "name": "Banana", + "category": "Fruit", + "calories": 89, + "protein": 1.1, + "fat": 0.3, + "portionsize": 100, + "sugars": 12.2, + "potassium": 358 + }, + { + "name": "Orange", + "category": "Fruit", + "calories": 47, + "protein": 0.9, + "fat": 0.1, + "portionsize": 100, + "sugars": 9.4, + "potassium": 181 + }, + { + "name": "Strawberry", + "category": "Fruit", + "calories": 32, + "protein": 0.7, + "fat": 0.3, + "portionsize": 100, + "sugars": 4.9, + "potassium": 153 + }, + { + "name": "Grapes", + "category": "Fruit", + "calories": 69, + "protein": 0.7, + "fat": 0.2, + "portionsize": 100, + "sugars": 15.5, + "potassium": 191 + }, + { + "name": "Blueberries", + "category": "Fruit", + "calories": 57, + "protein": 0.7, + "fat": 0.3, + "portionsize": 100, + "sugars": 9.7, + "potassium": 77 + }, + { + "name": "Mango", + "category": "Fruit", + "calories": 60, + "protein": 0.8, + "fat": 0.4, + "portionsize": 100, + "sugars": 14.8, + "potassium": 168 + }, + { + "name": "Pineapple", + "category": "Fruit", + "calories": 50, + "protein": 0.5, + "fat": 0.1, + "portionsize": 100, + "sugars": 9.9, + "potassium": 109 + }, + { + "name": "Carrot", + "category": "Vegetable", + "calories": 41, + "protein": 0.9, + "fat": 0.2, + "portionsize": 100, + "sugars": 4.7, + "potassium": 320 + }, + { + "name": "Broccoli", + "category": "Vegetable", + "calories": 34, + "protein": 2.8, + "fat": 0.4, + "portionsize": 100, + "sugars": 1.7, + "potassium": 316 + }, + { + "name": "Spinach", + "category": "Vegetable", + "calories": 23, + "protein": 2.9, + "fat": 0.4, + "portionsize": 100, + "sugars": 0.4, + "potassium": 558 + }, + { + "name": "Chicken Breast", + "category": "Meat", + "calories": 165, + "protein": 31, + "fat": 3.6, + "portionsize": 100, + "sugars": 0.0, + "potassium": 256 + }, + { + "name": "Salmon", + "category": "Fish", + "calories": 206, + "protein": 22, + "fat": 13, + "portionsize": 100, + "sugars": 0.0, + "potassium": 628 + }, + { + "name": "Brown Rice", + "category": "Grain", + "calories": 111, + "protein": 2.6, + "fat": 0.9, + "portionsize": 100, + "sugars": 0.4, + "potassium": 86 + }, + { + "name": "Quinoa", + "category": "Grain", + "calories": 120, + "protein": 4.1, + "fat": 1.9, + "portionsize": 100, + "sugars": 0.9, + "potassium": 318 + }, + { + "name": "Almonds", + "category": "Nuts", + "calories": 576, + "protein": 21, + "fat": 50, + "portionsize": 100, + "sugars": 4.4, + "potassium": 705 + }, + { + "name": "Walnuts", + "category": "Nuts", + "calories": 654, + "protein": 15, + "fat": 65, + "portionsize": 100, + "sugars": 2.6, + "potassium": 441 + }, + { + "name": "Greek Yogurt", + "category": "Dairy", + "calories": 59, + "protein": 10, + "fat": 0.4, + "portionsize": 100, + "sugars": 3.6, + "potassium": 141 + }, + { + "name": "Oats", + "category": "Grain", + "calories": 389, + "protein": 16.9, + "fat": 6.9, + "portionsize": 100, + "sugars": 0.9, + "potassium": 429 + }, + { + "name": "Egg", + "category": "Protein", + "calories": 155, + "protein": 13, + "fat": 11, + "portionsize": 100, + "sugars": 0.7, + "potassium": 126 + }, + { + "name": "Cottage Cheese", + "category": "Dairy", + "calories": 98, + "protein": 11, + "fat": 4.3, + "portionsize": 100, + "sugars": 3.0, + "potassium": 104 + }, + { + "name": "Sweet Potato", + "category": "Vegetable", + "calories": 86, + "protein": 1.6, + "fat": 0.1, + "portionsize": 100, + "sugars": 4.2, + "potassium": 337 + }, + { + "name": "Zucchini", + "category": "Vegetable", + "calories": 17, + "protein": 1.2, + "fat": 0.3, + "portionsize": 100, + "sugars": 2.0, + "potassium": 261 + } +] \ No newline at end of file -- GitLab From ea564dd117e46a81f69a17c5014e3dc596d89374 Mon Sep 17 00:00:00 2001 From: krishna <vamsi.sirigirisetty@pal.tech> Date: Wed, 13 Nov 2024 17:25:09 +0530 Subject: [PATCH 3/9] implemented exception handling --- .../DTO/RequestDTO/FoodCustomEntryDTO.cs | 1 + .../DTO/ResponseDTO/ActivityLogResponseDto.cs | 11 +++- .../Implementation/ActivityService.cs | 9 +-- .../Implementation/CustomLogger.cs | 58 +++++++++++++++++++ .../Implementation/FoodServices.cs | 4 +- .../Implementation/GroupChallengeServices.cs | 1 - .../Implementation/MappingProfile.cs | 1 + .../Implementation/UserService.cs | 7 +-- .../Interface/ICustomLogger.cs | 11 ++++ 9 files changed, 85 insertions(+), 18 deletions(-) create mode 100644 FoodTracker.Services/Implementation/CustomLogger.cs create mode 100644 FoodTracker.Services/Interface/ICustomLogger.cs diff --git a/FoodTracker.Services/DTO/RequestDTO/FoodCustomEntryDTO.cs b/FoodTracker.Services/DTO/RequestDTO/FoodCustomEntryDTO.cs index e8df415..cb14abe 100644 --- a/FoodTracker.Services/DTO/RequestDTO/FoodCustomEntryDTO.cs +++ b/FoodTracker.Services/DTO/RequestDTO/FoodCustomEntryDTO.cs @@ -10,6 +10,7 @@ public class FoodCustomEntryDTO public string? FoodItem { get; set; } [Required] public int PortionSize { get; set; } + public PortionType PortionSizeType { get; set; } [Required] public int Calories { get; set; } [Required] diff --git a/FoodTracker.Services/DTO/ResponseDTO/ActivityLogResponseDto.cs b/FoodTracker.Services/DTO/ResponseDTO/ActivityLogResponseDto.cs index c1c43c6..77de452 100644 --- a/FoodTracker.Services/DTO/ResponseDTO/ActivityLogResponseDto.cs +++ b/FoodTracker.Services/DTO/ResponseDTO/ActivityLogResponseDto.cs @@ -4,10 +4,15 @@ namespace FoodTracker.Services.DTO; public class ActivityLogResponseDto { + public ActivityLogResponseDto(){ + DefaultSleepingHours =8; + Defaultstepcount = 6000; + DefaulWaterIntake = 5; + } public ActivityDTO ActivityEntries { get; set; } - public int Defaultstepcount=6000; - public int DefaultSleepingHours=8; - public int DefaulWaterIntake=5; + public int Defaultstepcount{get;set;} + public int DefaultSleepingHours{get;set;} + public int DefaulWaterIntake{get;set;} public List<string> FeedbackMessages { get; set; } diff --git a/FoodTracker.Services/Implementation/ActivityService.cs b/FoodTracker.Services/Implementation/ActivityService.cs index 8a64e55..a3d7417 100644 --- a/FoodTracker.Services/Implementation/ActivityService.cs +++ b/FoodTracker.Services/Implementation/ActivityService.cs @@ -3,9 +3,8 @@ using AutoMapper; using FoodTracker.Database.Entity; using FoodTracker.Database.Interface; using FoodTracker.Services.DTO; -using FoodTracker.Utilites.CustomLogger; -using FoodTracker.Utilites; using FoodTracker.Services.Interface; +using FoodTracker.Utilites; namespace FoodTracker.Services.Implementation; @@ -24,8 +23,6 @@ public class ActivityService : IActivityService } public async Task<string> AddActivity(ActivityDTO activityDto, int userId) { - // Implement logic to add activity entry to the database - // Return a success message ActivityTracking activityData = _mapper.Map<ActivityTracking>(activityDto); activityData.UserId = userId; if(await _activityRepo.Create(activityData)){ @@ -49,7 +46,7 @@ public class ActivityService : IActivityService { return "Activity deleted successfully"; } - throw new DllNotFoundException("Activity not found or already deleted"); + throw new Exception("Activity not found or already deleted"); } @@ -88,7 +85,7 @@ public class ActivityService : IActivityService // Return feedback messages - return new ActivityLogResponseDto(){ActivityEntries=userActivityData,FeedbackMessages=feedbackMessages,DefaultSleepingHours=8,Defaultstepcount=6000,DefaulWaterIntake=5 + return new ActivityLogResponseDto(){ActivityEntries=userActivityData,FeedbackMessages=feedbackMessages, }; } diff --git a/FoodTracker.Services/Implementation/CustomLogger.cs b/FoodTracker.Services/Implementation/CustomLogger.cs new file mode 100644 index 0000000..05da27e --- /dev/null +++ b/FoodTracker.Services/Implementation/CustomLogger.cs @@ -0,0 +1,58 @@ + + +namespace FoodTracker.Services.Implementation; + +using FoodTracker.Database.Data; +using FoodTracker.Database.Entity; +using FoodTracker.Services.Interface; +using FoodTracker.Services.Implementation; +using Microsoft.Extensions.Logging; +using System; +using System.Threading.Tasks; + +public class CustomLogger : ICustomLogger +{ + private readonly ApplicationDbContext _context; + private readonly ILogger<CustomLogger> _logger; + + public CustomLogger(ApplicationDbContext context, ILogger<CustomLogger> logger) + { + _context = context; + _logger = logger; + } + + public async Task LogInformationAsync(string message, string userName, string email) + { + _logger.LogInformation(message); + await LogToDatabaseAsync("Information", message, userName, email); + } + + public async Task LogWarningAsync(string message, string userName, string email) + { + _logger.LogWarning(message); + await LogToDatabaseAsync("Warning", message, userName, email); + } + + public async Task LogErrorAsync(string message, string userName, string email, Exception exception = null) + { + _logger.LogError(exception, message); + await LogToDatabaseAsync("Error", message, userName, email, exception); + } + + private async Task LogToDatabaseAsync(string level, string message, string userName, string email, Exception exception = null) + { + var logEntry = new Logs + { + Timestamp = DateTime.UtcNow, + Level = level, + LoggedInTime = DateTime.UtcNow, // Adjust as necessary + UserName = userName, + Email = email, + Message = message, + Exception = exception?.ToString() // Store exception details if provided + }; + + _context.Logs.Add(logEntry); + await _context.SaveChangesAsync(); + } +} \ No newline at end of file diff --git a/FoodTracker.Services/Implementation/FoodServices.cs b/FoodTracker.Services/Implementation/FoodServices.cs index ca932c1..e271182 100644 --- a/FoodTracker.Services/Implementation/FoodServices.cs +++ b/FoodTracker.Services/Implementation/FoodServices.cs @@ -8,7 +8,7 @@ using FoodTracker.Services.Interface; using FoodTracker.Utilites; using Microsoft.Extensions.FileProviders; using Newtonsoft.Json; -using FoodTracker.Utilites.CustomLogger; + namespace FoodTracker.Services.Implementation; @@ -70,7 +70,7 @@ public class FoodServices : IFoodServices public FoodLogResponseDTO GetFoodLogs(int userId) { var foodLogs =_mapper.Map<List<FoodCustomEntryDTO>>(_foodRepo.Read(userId)); - int totalCalories = foodLogs.Sum(log => log.Calories); + int totalCalories = foodLogs.Sum(log => log.Calories); int calorieGoal = _foodRepo.GetGoalCalories(userId); return new FoodLogResponseDTO(){FoodEntries = foodLogs,CalorieGoal=calorieGoal,CalorieIntake=totalCalories}; diff --git a/FoodTracker.Services/Implementation/GroupChallengeServices.cs b/FoodTracker.Services/Implementation/GroupChallengeServices.cs index 5fe0e01..5fa1a92 100644 --- a/FoodTracker.Services/Implementation/GroupChallengeServices.cs +++ b/FoodTracker.Services/Implementation/GroupChallengeServices.cs @@ -5,7 +5,6 @@ using FoodTracker.Database.Interface; using FoodTracker.Services.DTO; using FoodTracker.Services.Interface; using FoodTracker.Utilites; -using FoodTracker.Utilites.CustomLogger; namespace FoodTracker.Services.Implementation; diff --git a/FoodTracker.Services/Implementation/MappingProfile.cs b/FoodTracker.Services/Implementation/MappingProfile.cs index b44e7a8..b7934cb 100644 --- a/FoodTracker.Services/Implementation/MappingProfile.cs +++ b/FoodTracker.Services/Implementation/MappingProfile.cs @@ -13,6 +13,7 @@ public class MappingProfile:Profile CreateMap<ApplicationUser,UserRegisterDTO>().ReverseMap(); CreateMap<FoodLogEntry,FoodCustomEntryDTO>().ReverseMap(); + CreateMap<FoodLogEntry,FoodEntryDTO>().ReverseMap(); CreateMap<MacroNutrients,MacroNutrientsDTO>().ReverseMap(); CreateMap<GroupChallenge,ChallengeDetailsDTO>().ReverseMap(); CreateMap<ActivityTracking, ActivityDTO>().ReverseMap(); diff --git a/FoodTracker.Services/Implementation/UserService.cs b/FoodTracker.Services/Implementation/UserService.cs index 6029c5f..f1e4eac 100644 --- a/FoodTracker.Services/Implementation/UserService.cs +++ b/FoodTracker.Services/Implementation/UserService.cs @@ -7,7 +7,6 @@ using FoodTracker.Services.DTO; using FoodTracker.Services.DTO.ResponseDTO; using FoodTracker.Services.Interface; using FoodTracker.Utilites; -using FoodTracker.Utilites.CustomLogger; namespace FoodTracker.Services.Implementation; @@ -66,7 +65,7 @@ public class UserServices : IUserService { if (_loggedInUser.Id == 0) { - System.Console.WriteLine("Login Required"); + throw new Exception("Login Kindly"); } //_userRepo.updateLogOutTime(_loggedInUser); _loggedInUser.Id = 0; @@ -107,12 +106,8 @@ public class UserServices : IUserService }catch(Exception ex){ throw new Exception(ex.Message); } - - - } - } diff --git a/FoodTracker.Services/Interface/ICustomLogger.cs b/FoodTracker.Services/Interface/ICustomLogger.cs new file mode 100644 index 0000000..2581139 --- /dev/null +++ b/FoodTracker.Services/Interface/ICustomLogger.cs @@ -0,0 +1,11 @@ +using System; + +namespace FoodTracker.Services.Interface; + +public interface ICustomLogger +{ + Task LogInformationAsync(string message, string userName, string email); + Task LogWarningAsync(string message, string userName, string email); + Task LogErrorAsync(string message, string userName, string email, Exception exception = null); +} + -- GitLab From 67811e4522f4888c19d443795ecbfdd87f40403b Mon Sep 17 00:00:00 2001 From: krishna <vamsi.sirigirisetty@pal.tech> Date: Wed, 13 Nov 2024 17:27:20 +0530 Subject: [PATCH 4/9] removed CustomLogger --- .../CustomLogger/CustomLogger.cs | 56 ------------------- .../CustomLogger/ICustomLogger.cs | 11 ---- .../FoodTracker.Utilites.csproj | 5 -- 3 files changed, 72 deletions(-) delete mode 100644 FoodTracker.Utilites/CustomLogger/CustomLogger.cs delete mode 100644 FoodTracker.Utilites/CustomLogger/ICustomLogger.cs diff --git a/FoodTracker.Utilites/CustomLogger/CustomLogger.cs b/FoodTracker.Utilites/CustomLogger/CustomLogger.cs deleted file mode 100644 index 15cad82..0000000 --- a/FoodTracker.Utilites/CustomLogger/CustomLogger.cs +++ /dev/null @@ -1,56 +0,0 @@ - - -namespace FoodTracker.Utilites.CustomLogger; - -using FoodTracker.Database.Data; -using FoodTracker.Database.Entity; -using Microsoft.Extensions.Logging; -using System; -using System.Threading.Tasks; - -public class CustomLogger : ICustomLogger -{ - private readonly ApplicationDbContext _context; - private readonly ILogger<CustomLogger> _logger; - - public CustomLogger(ApplicationDbContext context, ILogger<CustomLogger> logger) - { - _context = context; - _logger = logger; - } - - public async Task LogInformationAsync(string message, string userName, string email) - { - _logger.LogInformation(message); - await LogToDatabaseAsync("Information", message, userName, email); - } - - public async Task LogWarningAsync(string message, string userName, string email) - { - _logger.LogWarning(message); - await LogToDatabaseAsync("Warning", message, userName, email); - } - - public async Task LogErrorAsync(string message, string userName, string email, Exception exception = null) - { - _logger.LogError(exception, message); - await LogToDatabaseAsync("Error", message, userName, email, exception); - } - - private async Task LogToDatabaseAsync(string level, string message, string userName, string email, Exception exception = null) - { - var logEntry = new Logs - { - Timestamp = DateTime.UtcNow, - Level = level, - LoggedInTime = DateTime.UtcNow, // Adjust as necessary - UserName = userName, - Email = email, - Message = message, - Exception = exception?.ToString() // Store exception details if provided - }; - - _context.Logs.Add(logEntry); - await _context.SaveChangesAsync(); - } -} \ No newline at end of file diff --git a/FoodTracker.Utilites/CustomLogger/ICustomLogger.cs b/FoodTracker.Utilites/CustomLogger/ICustomLogger.cs deleted file mode 100644 index 30794c3..0000000 --- a/FoodTracker.Utilites/CustomLogger/ICustomLogger.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; - -namespace FoodTracker.Utilites.CustomLogger; - -public interface ICustomLogger -{ - Task LogInformationAsync(string message, string userName, string email); - Task LogWarningAsync(string message, string userName, string email); - Task LogErrorAsync(string message, string userName, string email, Exception exception = null); -} - diff --git a/FoodTracker.Utilites/FoodTracker.Utilites.csproj b/FoodTracker.Utilites/FoodTracker.Utilites.csproj index 0f209b2..1e916aa 100644 --- a/FoodTracker.Utilites/FoodTracker.Utilites.csproj +++ b/FoodTracker.Utilites/FoodTracker.Utilites.csproj @@ -1,9 +1,4 @@ <Project Sdk="Microsoft.NET.Sdk"> - - <ItemGroup> - <ProjectReference Include="..\FoodTracker.Database\FoodTracker.Database.csproj" /> - </ItemGroup> - <PropertyGroup> <TargetFramework>net8.0</TargetFramework> <ImplicitUsings>enable</ImplicitUsings> -- GitLab From 071a5285b882c6219c01a2d25ff96b54a4c604b4 Mon Sep 17 00:00:00 2001 From: krishna <vamsi.sirigirisetty@pal.tech> Date: Wed, 13 Nov 2024 17:29:10 +0530 Subject: [PATCH 5/9] modified gitignore file --- .gitignore | 3 ++- FoodTracker.Api/Program.cs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index e4df1dc..54a720c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ /*/bin /*/obj appsettings.json -appsettings.Development.json \ No newline at end of file +appsettings.Development.json +.vscode \ No newline at end of file diff --git a/FoodTracker.Api/Program.cs b/FoodTracker.Api/Program.cs index 108aa40..f101f85 100644 --- a/FoodTracker.Api/Program.cs +++ b/FoodTracker.Api/Program.cs @@ -18,7 +18,7 @@ builder.Services.AddDbContext<ApplicationDbContext>(options => ); builder.Services.AddEndpointsApiExplorer(); builder.Services.AddSwaggerGen(); -builder.Services.AddControllers().AddJsonOptions(options=>options.JsonSerializerOptions.ReferenceHandler=ReferenceHandler.IgnoreCycles);; +builder.Services.AddControllers().AddJsonOptions(options=>options.JsonSerializerOptions.ReferenceHandler=ReferenceHandler.IgnoreCycles); System.Console.WriteLine(builder.Configuration.GetSection("ConnectionStrings")["DefaultConnection"]); -- GitLab From c099c7a205d06775a7e7fd800bafd114b16170e9 Mon Sep 17 00:00:00 2001 From: krishna <vamsi.sirigirisetty@pal.tech> Date: Wed, 13 Nov 2024 17:33:33 +0530 Subject: [PATCH 6/9] modified naming conventions --- FoodTracker.Api/Program.cs | 8 ++++---- ...{Activitytracking.cs => ActivitytrackingRepository.cs} | 4 ++-- .../{FoodLogManager.cs => FoodLogRepository.cs} | 4 ++-- ...oupChallengeManager.cs => GroupChallengeRepository.cs} | 4 ++-- .../Implementation/{UserRepo.cs => UserRepository.cs} | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) rename FoodTracker.Database/Implementation/{Activitytracking.cs => ActivitytrackingRepository.cs} (93%) rename FoodTracker.Database/Implementation/{FoodLogManager.cs => FoodLogRepository.cs} (95%) rename FoodTracker.Database/Implementation/{GroupChallengeManager.cs => GroupChallengeRepository.cs} (95%) rename FoodTracker.Database/Implementation/{UserRepo.cs => UserRepository.cs} (96%) diff --git a/FoodTracker.Api/Program.cs b/FoodTracker.Api/Program.cs index f101f85..58e3763 100644 --- a/FoodTracker.Api/Program.cs +++ b/FoodTracker.Api/Program.cs @@ -30,14 +30,14 @@ System.Console.WriteLine(builder.Configuration.GetSection("ConnectionStrings")[" builder.Services.AddAutoMapper(typeof(MappingProfile)); builder.Services.AddScoped<IUserService, UserServices>(); -builder.Services.AddScoped<IUserRepo, UserRepo>(); +builder.Services.AddScoped<IUserRepo, UserRepository>(); builder.Services.AddScoped<IFoodServices, FoodServices>(); -builder.Services.AddScoped<IFoodRepo, FoodLogManager>(); +builder.Services.AddScoped<IFoodRepo, FoodLogRepository>(); builder.Services.AddScoped<ICustomLogger, CustomLogger>(); builder.Services.AddScoped<IGroupChallenge,GroupChallengeServices>(); -builder.Services.AddScoped<IChallengeRepo,GroupChallengeManager>(); +builder.Services.AddScoped<IChallengeRepo,GroupChallengeRepository>(); builder.Services.AddScoped<IActivityService, ActivityService>(); -builder.Services.AddScoped<IActivityRepo, Activitytracking>(); +builder.Services.AddScoped<IActivityRepo, ActivitytrackingRepository>(); builder.Services.AddSingleton<LoggedInUser>(); //builder.Services.AddSingleton<SmsSender>(); diff --git a/FoodTracker.Database/Implementation/Activitytracking.cs b/FoodTracker.Database/Implementation/ActivitytrackingRepository.cs similarity index 93% rename from FoodTracker.Database/Implementation/Activitytracking.cs rename to FoodTracker.Database/Implementation/ActivitytrackingRepository.cs index 00f99d9..c605289 100644 --- a/FoodTracker.Database/Implementation/Activitytracking.cs +++ b/FoodTracker.Database/Implementation/ActivitytrackingRepository.cs @@ -6,11 +6,11 @@ using FoodTracker.Utilites; namespace FoodTracker.Database.Implementation; -public class Activitytracking : IActivityRepo +public class ActivitytrackingRepository : IActivityRepo { private readonly ApplicationDbContext _context; private readonly LoggedInUser _loggedInUser; - public Activitytracking(ApplicationDbContext context,LoggedInUser loggedInUser) + public ActivitytrackingRepository(ApplicationDbContext context,LoggedInUser loggedInUser) { _context = context; _loggedInUser=loggedInUser; diff --git a/FoodTracker.Database/Implementation/FoodLogManager.cs b/FoodTracker.Database/Implementation/FoodLogRepository.cs similarity index 95% rename from FoodTracker.Database/Implementation/FoodLogManager.cs rename to FoodTracker.Database/Implementation/FoodLogRepository.cs index 0f4eb7c..0c1165b 100644 --- a/FoodTracker.Database/Implementation/FoodLogManager.cs +++ b/FoodTracker.Database/Implementation/FoodLogRepository.cs @@ -6,10 +6,10 @@ using Microsoft.EntityFrameworkCore; namespace FoodTracker.Database.Implementation; -public class FoodLogManager : IFoodRepo +public class FoodLogRepository : IFoodRepo { private readonly ApplicationDbContext _context; - public FoodLogManager(ApplicationDbContext context){ + public FoodLogRepository(ApplicationDbContext context){ _context = context; } public async Task<bool> Create(FoodLogEntry foodLog) diff --git a/FoodTracker.Database/Implementation/GroupChallengeManager.cs b/FoodTracker.Database/Implementation/GroupChallengeRepository.cs similarity index 95% rename from FoodTracker.Database/Implementation/GroupChallengeManager.cs rename to FoodTracker.Database/Implementation/GroupChallengeRepository.cs index 3a89a77..9e32dc5 100644 --- a/FoodTracker.Database/Implementation/GroupChallengeManager.cs +++ b/FoodTracker.Database/Implementation/GroupChallengeRepository.cs @@ -7,11 +7,11 @@ using Microsoft.EntityFrameworkCore; namespace FoodTracker.Database.Implementation; -public class GroupChallengeManager : IChallengeRepo +public class GroupChallengeRepository : IChallengeRepo { private readonly ApplicationDbContext _context; - public GroupChallengeManager(ApplicationDbContext context){ + public GroupChallengeRepository(ApplicationDbContext context){ _context = context; } public async Task<bool> CreateGroupChallenge(GroupChallenge groupChallenge) diff --git a/FoodTracker.Database/Implementation/UserRepo.cs b/FoodTracker.Database/Implementation/UserRepository.cs similarity index 96% rename from FoodTracker.Database/Implementation/UserRepo.cs rename to FoodTracker.Database/Implementation/UserRepository.cs index bd2cf6d..d9d3b0f 100644 --- a/FoodTracker.Database/Implementation/UserRepo.cs +++ b/FoodTracker.Database/Implementation/UserRepository.cs @@ -8,10 +8,10 @@ using Microsoft.EntityFrameworkCore; namespace FoodTracker.Database.Implementation; -public class UserRepo : IUserRepo +public class UserRepository : IUserRepo { private readonly ApplicationDbContext _context; - public UserRepo(ApplicationDbContext context){ + public UserRepository(ApplicationDbContext context){ _context = context; } -- GitLab From caa50eea3802479569d322a71dab0d9d79d051f4 Mon Sep 17 00:00:00 2001 From: krishna <vamsi.sirigirisetty@pal.tech> Date: Wed, 13 Nov 2024 17:36:03 +0530 Subject: [PATCH 7/9] resolved error --- .vscode/launch.json | 35 ++++++++++++++++++++++++++++++++ .vscode/tasks.json | 41 ++++++++++++++++++++++++++++++++++++++ FoodTracker.Api/Program.cs | 2 +- 3 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 .vscode/launch.json create mode 100644 .vscode/tasks.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..68336f4 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,35 @@ +{ + "version": "0.2.0", + "configurations": [ + { + // Use IntelliSense to find out which attributes exist for C# debugging + // Use hover for the description of the existing attributes + // For further information visit https://github.com/dotnet/vscode-csharp/blob/main/debugger-launchjson.md. + "name": ".NET Core Launch (web)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + // If you have changed target frameworks, make sure to update the program path. + "program": "${workspaceFolder}/FoodTracker.Api/bin/Debug/net8.0/FoodTracker.Api.dll", + "args": [], + "cwd": "${workspaceFolder}/FoodTracker.Api", + "stopAtEntry": false, + // Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser + "serverReadyAction": { + "action": "openExternally", + "pattern": "\\bNow listening on:\\s+(https?://\\S+)" + }, + "env": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "sourceFileMap": { + "/Views": "${workspaceFolder}/Views" + } + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach" + } + ] +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..cca3ec6 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,41 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/food-tracker.sln", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary;ForceNoAlign" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "publish", + "command": "dotnet", + "type": "process", + "args": [ + "publish", + "${workspaceFolder}/food-tracker.sln", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary;ForceNoAlign" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "watch", + "command": "dotnet", + "type": "process", + "args": [ + "watch", + "run", + "--project", + "${workspaceFolder}/food-tracker.sln" + ], + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/FoodTracker.Api/Program.cs b/FoodTracker.Api/Program.cs index 2aaf1e4..8229a75 100644 --- a/FoodTracker.Api/Program.cs +++ b/FoodTracker.Api/Program.cs @@ -6,7 +6,7 @@ using FoodTracker.Services.Interface; using FoodTracker.Services.Implementation; using FoodTracker.Database.Interface; using FoodTracker.Database.Implementation; - +using FoodTracker.Utilites.CustomLogger; using System.Text.Json.Serialization; using FoodTracker.Utilites; using FoodTracker.Database.Entity; -- GitLab From 227fbda73df23f2209228979e0dbcc32213cdf96 Mon Sep 17 00:00:00 2001 From: krishna <vamsi.sirigirisetty@pal.tech> Date: Wed, 13 Nov 2024 18:08:10 +0530 Subject: [PATCH 8/9] resolved merge --- .../Implementation/ActivitytrackingRepository.cs | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/FoodTracker.Database/Implementation/ActivitytrackingRepository.cs b/FoodTracker.Database/Implementation/ActivitytrackingRepository.cs index c605289..b254273 100644 --- a/FoodTracker.Database/Implementation/ActivitytrackingRepository.cs +++ b/FoodTracker.Database/Implementation/ActivitytrackingRepository.cs @@ -70,16 +70,7 @@ public class ActivitytrackingRepository : IActivityRepo public async Task<bool> Update(ActivityTracking activitylog) { - try - { - _context.UserActivity.Update(activitylog); - await _context.SaveChangesAsync(); - return true; - } - catch (Exception ex) - { - throw new Exception(ex.Message); - } + } -- GitLab From d81447c46b92874dcb0511c81c3f8bb3d260e03a Mon Sep 17 00:00:00 2001 From: krishna <vamsi.sirigirisetty@pal.tech> Date: Wed, 13 Nov 2024 18:10:13 +0530 Subject: [PATCH 9/9] temp --- .../Implementation/ActivitytrackingRepository.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/FoodTracker.Database/Implementation/ActivitytrackingRepository.cs b/FoodTracker.Database/Implementation/ActivitytrackingRepository.cs index b254273..c605289 100644 --- a/FoodTracker.Database/Implementation/ActivitytrackingRepository.cs +++ b/FoodTracker.Database/Implementation/ActivitytrackingRepository.cs @@ -70,7 +70,16 @@ public class ActivitytrackingRepository : IActivityRepo public async Task<bool> Update(ActivityTracking activitylog) { - + try + { + _context.UserActivity.Update(activitylog); + await _context.SaveChangesAsync(); + return true; + } + catch (Exception ex) + { + throw new Exception(ex.Message); + } } -- GitLab