public ActionResult AddIngredient(string ingredient, string quantity) { var userClaims = User.Identity as System.Security.Claims.ClaimsIdentity; ViewBag.Name = userClaims?.FindFirst("name")?.Value; PantryEntity pantryEntity = new PantryEntity(userClaims?.FindFirst(System.IdentityModel.Claims.ClaimTypes.Name)?.Value, ingredient); pantryEntity.foodCategory = "food"; pantryEntity.quantity = quantity; pantryEntity.ExpirationTime = DateTime.UtcNow; TableActions.AddRow("PantryTable", (TableEntity)pantryEntity); var results = TableActions.GetPantryResult("PantryTable", userClaims?.FindFirst(System.IdentityModel.Claims.ClaimTypes.Name)?.Value); List <PantryModel> pantryItems = new List <PantryModel>(); foreach (var item in results) { var pantryItem = item as PantryEntity; pantryItems.Add(new PantryModel { Item = pantryItem.RowKey, Quantity = pantryItem.quantity }); } return(View("Index", pantryItems)); }
public ActionResult Create(PreferencesModel model) { var userClaims = User.Identity as System.Security.Claims.ClaimsIdentity; ViewBag.Name = userClaims?.FindFirst("name")?.Value; if (model.DietaryRestrictions == null) { model.DietaryRestrictions = new List <EdamamService.Health>(); } PreferenceEntity preferences = new PreferenceEntity(userClaims?.FindFirst(System.IdentityModel.Claims.ClaimTypes.Name)?.Value, userClaims?.FindFirst(System.IdentityModel.Claims.ClaimTypes.Name)?.Value) { dietPreference = model.Diet.ToString(), healthPreference = string.Join(",", model.DietaryRestrictions.Select(x => x.ToString())) }; TableActions.AddRow("PreferenceTable", (TableEntity)preferences); return(View("Index", model)); }