public void AddMeal(int userId, DateTime date, string mealName, DateTime time, double caloriesSupplied) { if (!Verify(userId)) { throw new SoapException("Nie rozpoznano użytkownika.", SoapException.ClientFaultCode); } else { bool contains = false; //int mealId = 0; using (var dB = new DailyServerContext()) { contains = dB.DailyInscriptionSet.AsEnumerable().Any(row => (date == row.Date & userId == row.UserUserId)); DailyInscription newDailyInscription; if (!contains) { newDailyInscription = new DailyInscription() { Date = date, UserUserId = userId, }; dB.DailyInscriptionSet.Add(newDailyInscription); dB.SaveChanges(); } else { newDailyInscription = (from DailyInscriptionSet in dB.DailyInscriptionSet where DailyInscriptionSet.Date == date && DailyInscriptionSet.UserUserId == userId select DailyInscriptionSet).FirstOrDefault(); } var newDailyMeal = new DailyMeal() { DMealName = mealName, Time = time, CaloriesSupplied = caloriesSupplied, DailyInscription = newDailyInscription, }; dB.DailyMealSet.Add(newDailyMeal); dB.SaveChanges(); //mealId = (from DailyMealSet in dB.DailyMealSet // where DailyMealSet.DailyInscriptionDInscriptionId == newDailyInscription.DInscriptionId // select DailyMealSet.DMealId).FirstOrDefault(); ; } //return mealId; } }
public void UpdateTargetInfo(int userId, DateTime newTargetDate, double newTargetWeight, double newTargetBodyFat) { if (!Verify(userId)) { throw new SoapException("Nie rozpoznano użytkownika.", SoapException.ClientFaultCode); } else { using (var dB = new DailyServerContext()) { var updateUserTarget = from UserTargetSet in dB.UserTargetSet where UserTargetSet.User.UserId == userId select UserTargetSet; UserTarget userTarget = updateUserTarget.Single(); userTarget.Date = newTargetDate; userTarget.Weight = newTargetWeight; userTarget.BodyFat = newTargetBodyFat; dB.SaveChanges(); } } }
public List<ProductCategoryHelper> GetProductsCategories() { List<ProductCategory> productCategory = new List<ProductCategory>(); List<ProductCategoryHelper> productCategoryHelper = new List<ProductCategoryHelper>(); using (var dB = new DailyServerContext()) { productCategory = dB.ProductCategorySet.ToList(); for (int i = 0; i < productCategory.Count; i++) { productCategoryHelper.Add(new ProductCategoryHelper() { PCategoryId = productCategory[i].PCategoryId, PCategoryName = productCategory[i].PCategoryName }); } } return productCategoryHelper; }
public List<MensurationTypeHelper> GetMensurationTypes() { List<TypeOfMensuration> typeOfMensuration = new List<TypeOfMensuration>(); List<MensurationTypeHelper> mensurationTypeHelper = new List<MensurationTypeHelper>(); using (var dB = new DailyServerContext()) { typeOfMensuration = dB.TypeOfMensurationSet.ToList(); for (int i = 0; i < typeOfMensuration.Count; i++) { mensurationTypeHelper.Add(new MensurationTypeHelper() { MTypeId = typeOfMensuration[i].TOfMensurationId, MName = typeOfMensuration[i].MName }); } } return mensurationTypeHelper; }
public List<ProductHelper> GetMealProducts(int mealId) { List<ProductHelper> productHelper; using (var dB = new DailyServerContext()) { var whoseIsThisMeal = (from DailyMealSet in dB.DailyMealSet where DailyMealSet.DMealId == mealId select DailyMealSet.DailyInscription.UserUserId).FirstOrDefault(); if (!Verify(whoseIsThisMeal.Value)) { throw new SoapException("Nie rozpoznano użytkownika.", SoapException.ClientFaultCode); } else { productHelper = new List<ProductHelper>(); var mealProducts = from ProductsOfMealSet in dB.ProductsOfMealSet where ProductsOfMealSet.DailyMealDMealId == mealId select ProductsOfMealSet; foreach (var product in mealProducts) { string productType = null; if (product.ProductTypePTypeId == 1) { productType = "ml"; } else if (product.ProductTypePTypeId == 2) { productType = "g"; } else if (product.ProductTypePTypeId == 3) { productType = "szt"; } productHelper.Add(new ProductHelper() { ProductId = product.POMealId, PName = product.PName, ProductType = productType, Amount = product.Amount, Calories = product.Calories, Proteins = product.Proteins, Carbohydrates = product.Carbohydrates, Fat = product.Fat }); } return productHelper; } } }
public List<ExerciseCategoryHelper> GetExerciseCategories() { List<ExerciseCategory> exerciseCategory = new List<ExerciseCategory>(); List<ExerciseCategoryHelper> exerciseCategoryHelper = new List<ExerciseCategoryHelper>(); using (var dB = new DailyServerContext()) { exerciseCategory = dB.ExerciseCategorySet.ToList(); for (int i = 0; i < exerciseCategory.Count; i++) { exerciseCategoryHelper.Add(new ExerciseCategoryHelper() { ECategoryId = exerciseCategory[i].ECategoryId, ECategoryName = exerciseCategory[i].ECategoryName }); } } return exerciseCategoryHelper; }
public List<DailyPhotoHelper> GetDailyPhotoInscription(int userId, DateTime date) { if (!Verify(userId)) { throw new SoapException("Nie rozpoznano użytkownika.", SoapException.ClientFaultCode); } else { List<DailyPhotoHelper> myPhotoInscription = new List<DailyPhotoHelper>(); using (var dB = new DailyServerContext()) { var DailyPhoto = from DailyPhotoSet in dB.DailyPhotoSet where DailyPhotoSet.DailyInscription.UserUserId == userId && DailyPhotoSet.DailyInscription.Date == date select DailyPhotoSet; foreach (var myPhoto in DailyPhoto) { myPhotoInscription.Add(new DailyPhotoHelper() { DPhotoId = myPhoto.DPhotoId, PName = myPhoto.PName, PContent = myPhoto.PContent }); } } return myPhotoInscription; } }
public TargetAndCaloriesNeedHelper GetActualProgress(int userId) { if (!Verify(userId)) { throw new SoapException("Nie rozpoznano użytkownika.", SoapException.ClientFaultCode); } else { TargetAndCaloriesNeedHelper tAndCNeedHelper; List<DailyMensurationHelper> myMensurationInscription = new List<DailyMensurationHelper>(); using (var dB = new DailyServerContext()) { var newestProgress = (from x in dB.DailyInscriptionSet where x.DailyMensuration.Count > 0 && x.UserUserId == userId select x).OrderByDescending(x => x.Date); tAndCNeedHelper = new TargetAndCaloriesNeedHelper(); foreach (var item in newestProgress) { foreach (var dm in item.DailyMensuration) { if (dm.TypeOfMensuration.MName == "Współczynnik BF") { tAndCNeedHelper.TargetBodyFat = dm.MResultValue; } else if (dm.TypeOfMensuration.MName == "Waga") { tAndCNeedHelper.TargetWeight = dm.MResultValue; } } if (tAndCNeedHelper.TargetBodyFat != 0 && tAndCNeedHelper.TargetWeight != 0) { tAndCNeedHelper.TargetDate = item.Date; break; } else { tAndCNeedHelper.TargetBodyFat = tAndCNeedHelper.TargetWeight = 0; } } } return tAndCNeedHelper; } }
public bool DeleteDailyPhotoInscription(int userId, int photoId) { if (!Verify(userId)) { throw new SoapException("Nie rozpoznano użytkownika.", SoapException.ClientFaultCode); } else { try { using (var dB = new DailyServerContext()) { var deletePhoto = dB.DailyPhotoSet.First(row => (row.DPhotoId == photoId && row.DailyInscription.UserUserId == userId)); dB.DailyPhotoSet.Remove(deletePhoto); dB.SaveChanges(); } return true; } catch (Exception) { return false; } } }
public void DeleteDailyMensurationInscription(int userId, int mResultId) { if (!Verify(userId)) { throw new SoapException("Nie rozpoznano użytkownika.", SoapException.ClientFaultCode); } else { using (var dB = new DailyServerContext()) { var deleteMensuration = dB.DailyMensurationSet.First(row => (row.MResultId == mResultId && row.DailyInscription.UserUserId == userId)); dB.DailyMensurationSet.Remove(deleteMensuration); dB.SaveChanges(); } } }
public bool AddUsersOwnProduct(int userId, string productName, int productType, double productProteins, double productCarbohydrates, double productFat, double productCalories) { if (!Verify(userId)) { throw new SoapException("Nie rozpoznano użytkownika.", SoapException.ClientFaultCode); } else { try { using (var dB = new DailyServerContext()) { var newUsersProduct = new UserProduct() { PName = productName, ProductCategoryPCategoryId = 12, //productCategory, ProductTypePTypeId = productType, Proteins = productProteins, Carbohydrates = productCarbohydrates, Fat = productFat, Calories = productCalories, UserUserId = userId }; dB.UserProductSet.Add(newUsersProduct); dB.SaveChanges(); } return true; } catch (Exception) { return false; } } }
public bool AddProductOfMeal(int mealId, string productName, int amount, int productType, double proteins, double carbohydrates, double fat, double calories, double newMealCaloriesValue) { try { using (var dB = new DailyServerContext()) { var whoseIsThisMeal = (from DailyMealSet in dB.DailyMealSet where DailyMealSet.DMealId == mealId select DailyMealSet.DailyInscription.UserUserId).FirstOrDefault(); if (!Verify(whoseIsThisMeal.Value)) { throw new SoapException("Nie rozpoznano użytkownika.", SoapException.ClientFaultCode); } else { var newProductsOfMeal = new ProductsOfMeal() { PName = productName, Amount = amount, ProductTypePTypeId = productType, Proteins = proteins, Carbohydrates = carbohydrates, Fat = fat, Calories = calories, DailyMealDMealId = mealId }; dB.ProductsOfMealSet.Add(newProductsOfMeal); dB.SaveChanges(); var updateMealCalories = from DailyMealSet in dB.DailyMealSet where DailyMealSet.DMealId == mealId select DailyMealSet; DailyMeal meal = updateMealCalories.Single(); meal.CaloriesSupplied = newMealCaloriesValue; dB.SaveChanges(); } return true; } } catch (Exception) { return false; } }
public void AddNewDailyTrainingInscription(int userId, DateTime date, int exerciseSerieNumber, int? repetitions, int? timeInMin, int exerciseId, int? weight = null) { if (!Verify(userId)) { throw new SoapException("Nie rozpoznano użytkownika.", SoapException.ClientFaultCode); } else { bool contains = false; using (var dB = new DailyServerContext()) { contains = dB.DailyInscriptionSet.AsEnumerable().Any(row => (date == row.Date & userId == row.UserUserId)); DailyInscription newDailyInscription; if (!contains) { newDailyInscription = new DailyInscription() { Date = date, UserUserId = userId, }; dB.DailyInscriptionSet.Add(newDailyInscription); dB.SaveChanges(); } else { newDailyInscription = (from DailyInscriptionSet in dB.DailyInscriptionSet where DailyInscriptionSet.Date == date && DailyInscriptionSet.UserUserId == userId select DailyInscriptionSet).FirstOrDefault(); } var newDailyTraining = new DailyTraining() { ESNumber = exerciseSerieNumber, Repetitions = repetitions, TimeInMin = timeInMin, Weight = weight, DailyInscription = newDailyInscription, ExerciseExerciseId = exerciseId, }; dB.DailyTrainingSet.Add(newDailyTraining); dB.SaveChanges(); } } }
public void AddNewDailyPhotoInscription(int userId, DateTime date, string fileName, byte[] chosenFile) { if (!Verify(userId)) { throw new SoapException("Nie rozpoznano użytkownika.", SoapException.ClientFaultCode); } else { bool contains = false; using (var dB = new DailyServerContext()) { contains = dB.DailyInscriptionSet.AsEnumerable().Any(row => (date == row.Date & userId == row.UserUserId)); DailyInscription newDailyInscription; if (!contains) { newDailyInscription = new DailyInscription() { Date = date, UserUserId = userId, }; dB.DailyInscriptionSet.Add(newDailyInscription); dB.SaveChanges(); } else { newDailyInscription = (from DailyInscriptionSet in dB.DailyInscriptionSet where DailyInscriptionSet.Date == date && DailyInscriptionSet.UserUserId == userId select DailyInscriptionSet).FirstOrDefault(); } var newDailyPhoto = new DailyPhoto() { PName = fileName, PContent = chosenFile, DailyInscription = newDailyInscription, }; dB.DailyPhotoSet.Add(newDailyPhoto); dB.SaveChanges(); } } }
private bool Verify(int userId) { using (var dB = new DailyServerContext()) { var verifyUser = from UserSet in dB.UserSet where UserSet.UserId == userId select UserSet; User user = verifyUser.FirstOrDefault(); if (authenticationHeader._login != user.Login.Trim() && authenticationHeader._password != user.Password.Trim()) { return false; } else { return true; } } }
public void EditMensurationInscription(int userId, int mResultId, double newMResultValue) { if (!Verify(userId)) { throw new SoapException("Nie rozpoznano użytkownika.", SoapException.ClientFaultCode); } else { using (var dB = new DailyServerContext()) { var updateMensuration = (from DailyMensurationSet in dB.DailyMensurationSet where DailyMensurationSet.MResultId == mResultId select DailyMensurationSet).FirstOrDefault(); updateMensuration.MResultValue = newMResultValue; dB.SaveChanges(); } } }
public void EditUsersProduct(int userId, int editedProductId, string newProductName, int newProductType,double newProteinsValue, double newCarbohydratesValue, double newFatValue, double newCaloriesValue) { if (!Verify(userId)) { throw new SoapException("Nie rozpoznano użytkownika.", SoapException.ClientFaultCode); } else { using (var dB = new DailyServerContext()) { var updateUserProduct = from UserProductSet in dB.UserProductSet where UserProductSet.UserUserId == userId && UserProductSet.UProductId == editedProductId select UserProductSet; UserProduct product = updateUserProduct.Single(); product.PName = newProductName; product.ProductTypePTypeId = newProductType; product.Proteins = newProteinsValue; product.Carbohydrates = newCarbohydratesValue; product.Fat = newFatValue; product.Calories = newCaloriesValue; dB.SaveChanges(); } } }
public void DeleteDailyTrainingExerciseSet(int userId, int exerciseSetId) { if (!Verify(userId)) { throw new SoapException("Nie rozpoznano użytkownika.", SoapException.ClientFaultCode); } else { using (var dB = new DailyServerContext()) { var deleteTrainingSet = dB.DailyTrainingSet.First(row => (row.ESetId == exerciseSetId && row.DailyInscription.UserUserId == userId)); dB.DailyTrainingSet.Remove(deleteTrainingSet); dB.SaveChanges(); } } }
public List<DailyMensurationHelper> GetDailyMensurationInscription(int userId, DateTime date) { if (!Verify(userId)) { throw new SoapException("Nie rozpoznano użytkownika.", SoapException.ClientFaultCode); } else { List<DailyMensurationHelper> myMensurationInscription = new List<DailyMensurationHelper>(); using (var dB = new DailyServerContext()) { var DailyMensuration = from DailyMensurationSet in dB.DailyMensurationSet where DailyMensurationSet.DailyInscription.UserUserId == userId && DailyMensurationSet.DailyInscription.Date == date select DailyMensurationSet; foreach (var myMensuration in DailyMensuration) { myMensurationInscription.Add(new DailyMensurationHelper() { MResultId = myMensuration.MResultId, MResultValue = myMensuration.MResultValue, MTypeId = (int)myMensuration.TypeOfMensurationTOfMensurationId }); } } return myMensurationInscription; } }
public void DeleteMeal(int mealId) { using (var dB = new DailyServerContext()) { var whoseIsThisMeal = (from DailyMealSet in dB.DailyMealSet where DailyMealSet.DMealId == mealId select DailyMealSet.DailyInscription.UserUserId).FirstOrDefault(); if (!Verify(whoseIsThisMeal.Value)) { throw new SoapException("Nie rozpoznano użytkownika.", SoapException.ClientFaultCode); } else { var deleteMealProducts = from ProductsOfMealSet in dB.ProductsOfMealSet where ProductsOfMealSet.DailyMealDMealId == mealId select ProductsOfMealSet; foreach (var product in deleteMealProducts) { dB.ProductsOfMealSet.Remove(product); } var deleteMeal = (from DailyMealSet in dB.DailyMealSet where DailyMealSet.DMealId == mealId select DailyMealSet).FirstOrDefault(); dB.DailyMealSet.Remove(deleteMeal); dB.SaveChanges(); } } }
public List<DailyTrainingHelper> GetDailyTrainigInscription(int userId, DateTime date) { if (!Verify(userId)) { throw new SoapException("Nie rozpoznano użytkownika.", SoapException.ClientFaultCode); } else { List<DailyTrainingHelper> myTrainingInscription = new List<DailyTrainingHelper>(); using (var dB = new DailyServerContext()) { var DailyTraining = from DailyTrainingSet in dB.DailyTrainingSet where DailyTrainingSet.DailyInscription.UserUserId == userId && DailyTrainingSet.DailyInscription.Date == date select DailyTrainingSet; foreach (var myTraining in DailyTraining) { myTrainingInscription.Add(new DailyTrainingHelper() { ExerciseName = myTraining.Exercise.EName, ESNumber = myTraining.ESNumber, Repetitions = myTraining.Repetitions, TimeInMin = myTraining.TimeInMin, Weight = myTraining.Weight, ExerciseSetId = myTraining.ESetId, DailyTrainingDTrainingId = myTraining.DailyInscriptionDInscriptionId, }); } } return myTrainingInscription; } }
public void DeleteProductOfMeal(int deletedProductId, double newMealCaloriesSupplied) { using (var dB = new DailyServerContext()) { var whoseIsThisMeal = (from ProductsOfMealSet in dB.ProductsOfMealSet where ProductsOfMealSet.POMealId == deletedProductId select ProductsOfMealSet.DailyMeal.DailyInscription.UserUserId).FirstOrDefault(); if (!Verify(whoseIsThisMeal.Value)) { throw new SoapException("Nie rozpoznano użytkownika.", SoapException.ClientFaultCode); } else { var deleteMealProduct = (from ProductsOfMealSet in dB.ProductsOfMealSet where ProductsOfMealSet.POMealId == deletedProductId select ProductsOfMealSet).FirstOrDefault(); double productCalories = deleteMealProduct.Calories; int mealId = deleteMealProduct.DailyMealDMealId; dB.ProductsOfMealSet.Remove(deleteMealProduct); dB.SaveChanges(); var updateMealCalories = from DailyMealSet in dB.DailyMealSet where DailyMealSet.DMealId == mealId select DailyMealSet; DailyMeal meal = updateMealCalories.Single(); meal.CaloriesSupplied = meal.CaloriesSupplied - productCalories; dB.SaveChanges(); } } }
public List<ExerciseHelper> GetExercisesOfChoosenCategory(int choosenCategory) { List<Exercise> exercise = new List<Exercise>(); List<ExerciseHelper> exerciseHelper = new List<ExerciseHelper>(); using (var dB = new DailyServerContext()) { var chosenExercises = from ExerciseSet in dB.ExerciseSet where ExerciseSet.ExerciseCategoryECategoryId == choosenCategory select ExerciseSet; exercise = chosenExercises.ToList(); for (int i = 0; i < exercise.Count; i++) { exerciseHelper.Add(new ExerciseHelper() { ExerciseId = exercise[i].ExerciseId, EName = exercise[i].EName }); } } return exerciseHelper; }
public bool DeleteUsersProduct(int userId, int productId) { if (!Verify(userId)) { throw new SoapException("Nie rozpoznano użytkownika.", SoapException.ClientFaultCode); } else { try { using (var dB = new DailyServerContext()) { var deleteUsersProduct = dB.UserProductSet.First(row => (row.UserUserId == userId && row.UProductId == productId)); dB.UserProductSet.Remove(deleteUsersProduct); dB.SaveChanges(); } return true; } catch (Exception) { return false; } } }
public List<DailyMealHelper> GetMeals(int userId, DateTime date) { if (!Verify(userId)) { throw new SoapException("Nie rozpoznano użytkownika.", SoapException.ClientFaultCode); } else { List<DailyMealHelper> myMealInscription = new List<DailyMealHelper>(); using (var dB = new DailyServerContext()) { var DailyMeal = from DailyMealSet in dB.DailyMealSet where DailyMealSet.DailyInscription.UserUserId == userId && DailyMealSet.DailyInscription.Date == date select DailyMealSet; foreach (var myMeal in DailyMeal) { myMealInscription.Add(new DailyMealHelper() { DMealId = myMeal.DMealId, DMealName = myMeal.DMealName, Time = myMeal.Time, CaloriesSupplied = myMeal.CaloriesSupplied }); } } return myMealInscription; } }
public void EditMeal(int mealId, string newMealName, DateTime newMealTime) { using (var dB = new DailyServerContext()) { var whoseIsThisMeal = (from DailyMealSet in dB.DailyMealSet where DailyMealSet.DMealId == mealId select DailyMealSet.DailyInscription.UserUserId).FirstOrDefault(); if (!Verify(whoseIsThisMeal.Value)) { throw new SoapException("Nie rozpoznano użytkownika.", SoapException.ClientFaultCode); } else { var editedMeal = from DailyMealSet in dB.DailyMealSet where DailyMealSet.DMealId == mealId select DailyMealSet; DailyMeal meal = editedMeal.Single(); meal.DMealName = newMealName; meal.Time = newMealTime; dB.SaveChanges(); } } }
public void AddNewDailyMensurationInscription(int userId, DateTime date, int mensurationTypeId, double mensurationResultValue) { if (!Verify(userId)) { throw new SoapException("Nie rozpoznano użytkownika.", SoapException.ClientFaultCode); } else { bool contains = false; using (var dB = new DailyServerContext()) { contains = dB.DailyInscriptionSet.AsEnumerable().Any(row => (date == row.Date & userId == row.UserUserId)); DailyInscription newDailyInscription; if (!contains) { newDailyInscription = new DailyInscription() { Date = date, UserUserId = userId, }; dB.DailyInscriptionSet.Add(newDailyInscription); dB.SaveChanges(); } else { newDailyInscription = (from DailyInscriptionSet in dB.DailyInscriptionSet where DailyInscriptionSet.Date == date && DailyInscriptionSet.UserUserId == userId select DailyInscriptionSet).FirstOrDefault(); } var newDailyMensuration = new DailyMensuration() { TypeOfMensurationTOfMensurationId = mensurationTypeId, MResultValue = mensurationResultValue, DailyInscription = newDailyInscription, }; dB.DailyMensurationSet.Add(newDailyMensuration); dB.SaveChanges(); } } }
public void EditMealProduct(int editedProductId, int newProductAmount, double newMealCaloriesSupplied) { using (var dB = new DailyServerContext()) { var whoseIsThisMeal = (from ProductsOfMealSet in dB.ProductsOfMealSet where ProductsOfMealSet.POMealId == editedProductId select ProductsOfMealSet.DailyMeal.DailyInscription.UserUserId).FirstOrDefault(); if (!Verify(whoseIsThisMeal.Value)) { throw new SoapException("Nie rozpoznano użytkownika.", SoapException.ClientFaultCode); } else { var updateProductAmount = from ProductsOfMealSet in dB.ProductsOfMealSet where ProductsOfMealSet.POMealId == editedProductId select ProductsOfMealSet; ProductsOfMeal mealProduct = updateProductAmount.Single(); double percentValue = (double) newProductAmount / (double) mealProduct.Amount * 100; mealProduct.Proteins *= percentValue / 100; mealProduct.Carbohydrates *= percentValue / 100; mealProduct.Fat *= percentValue / 100; mealProduct.Calories = (mealProduct.Proteins * 4) + (mealProduct.Carbohydrates * 4) + (mealProduct.Fat * 9); mealProduct.Amount = newProductAmount; var updateMealCalories = from DailyMealSet in dB.DailyMealSet where DailyMealSet.DMealId == mealProduct.DailyMealDMealId select DailyMealSet; DailyMeal meal = updateMealCalories.Single(); meal.CaloriesSupplied = newMealCaloriesSupplied; dB.SaveChanges(); } } }
public List<ProductHelper> GetProductsOfChosenCategory(int chosenCategory) { List<Product> products = new List<Product>(); List<ProductHelper> productHelper = new List<ProductHelper>(); using (var dB = new DailyServerContext()) { var chosenProducts = from ProductSet in dB.ProductSet where ProductSet.ProductCategoryPCategoryId == chosenCategory select ProductSet; var chosenUserProducts = from UserProductSet in dB.UserProductSet where UserProductSet.ProductCategoryPCategoryId == chosenCategory select UserProductSet; if (chosenProducts.Count() > 0) { products = chosenProducts.ToList(); } else if (chosenUserProducts.Count() > 0) { foreach (var product in chosenUserProducts) { products.Add(new Product { ProductId = product.UProductId, PName = product.PName, Calories = product.Calories, Proteins = product.Proteins, Carbohydrates = product.Carbohydrates, Fat = product.Fat, ProductTypePTypeId = product.ProductTypePTypeId }); } } for (int i = 0; i < products.Count; i++) { string productType = null; if (products[i].ProductTypePTypeId == 1) { productType = "ml"; } else if (products[i].ProductTypePTypeId == 2) { productType = "g"; } else if (products[i].ProductTypePTypeId == 3) { productType = "szt"; } productHelper.Add(new ProductHelper() { ProductId = products[i].ProductId, PName = products[i].PName, Calories = products[i].Calories, Proteins = products[i].Proteins, Carbohydrates = products[i].Carbohydrates, Fat = products[i].Fat, ProductType = productType, }); } return productHelper; } }
public void UpdateProfileInfo(int userId, string name, string surname, string aboutMe, string eMail, string password) { if (!Verify(userId)) { throw new SoapException("Nie rozpoznano użytkownika.", SoapException.ClientFaultCode); } else { using (var dB = new DailyServerContext()) { var updateUser = from UserSet in dB.UserSet where UserSet.UserId == userId select UserSet; User user = updateUser.Single(); user.Name = name; user.Surname = surname; user.Password = password; user.AboutMe = aboutMe; user.eMail = eMail; dB.SaveChanges(); } } }