protected async override Task UpdateAsync(FarmingEntities db, UserViewModel model) { var user = await db.Users.FindAsync(model.Id); if (user != null) { user.Login = model.Login; user.Password = model.Password; user.LastName = model.LastName; user.FirstName = model.FirstName; user.MiddleName = model.MiddleName; user.Phone = model.Phone.Value; user.UserTypeId = model.UserTypeId; await db.SaveChangesAsync(); var userVm = Models.FirstOrDefault(u => u.Id == user.Id); if (userVm != null) { userVm.Login = model.Login; userVm.Password = model.Password; userVm.LastName = model.LastName; userVm.FirstName = model.FirstName; userVm.MiddleName = model.MiddleName; userVm.Phone = model.Phone.Value; userVm.UserTypeId = model.UserTypeId; userVm.UserType = model.UserType; } } }
protected async override Task UpdateAsync(FarmingEntities db, ProductivityViewModel model) { var productivity = await db.Productivities.FindAsync(model.Id); if (productivity != null) { productivity.CowId = model.CowId; productivity.UchtenoLaktacij = model.UchtenoLaktacij.Value; productivity.UdojKg = model.UdojKg.Value; productivity.ZhirProz = model.ZhirProz.Value; productivity.BelokProz = model.BelokProz.Value; productivity.Date = model.Date.Value; await db.SaveChangesAsync(); var productivityVm = Models.FirstOrDefault(p => p.Id == productivity.Id); if (productivityVm != null) { productivityVm.CowId = model.CowId; productivityVm.Cow = model.Cow; productivityVm.UchtenoLaktacij = model.UchtenoLaktacij; productivityVm.UdojKg = model.UdojKg; productivityVm.ZhirProz = model.ZhirProz; productivityVm.BelokProz = model.BelokProz; productivityVm.Date = model.Date; } } }
protected async override Task UpdateAsync(FarmingEntities db, ReproductionViewModel model) { var reproduction = await db.Reproductions.FindAsync(model.Id); if (reproduction != null) { reproduction.BullId = model.BullId; reproduction.CowId = model.CowId; reproduction.MethodSluchkiId = model.MethodSluchkiId; reproduction.DateOsemeneniya = model.DateOsemeneniya.Value; reproduction.ChisloSuhihDney = model.ChisloSuhihDney.Value; reproduction.SerPeriod = model.SerPeriod.Value; reproduction.DateOtela = model.DateOtela.Value; await db.SaveChangesAsync(); var reproductionVm = Models.FirstOrDefault(r => r.Id == reproduction.Id); if (reproductionVm != null) { reproductionVm.BullId = model.BullId; reproductionVm.Bull = model.Bull; reproductionVm.CowId = model.CowId; reproductionVm.Cow = model.Cow; reproductionVm.MethodSluchkiId = model.MethodSluchkiId; reproductionVm.MethodSluchki = model.MethodSluchki; reproductionVm.DateOsemeneniya = model.DateOsemeneniya; reproductionVm.ChisloSuhihDney = model.ChisloSuhihDney; reproductionVm.SerPeriod = model.SerPeriod; reproductionVm.DateOtela = model.DateOtela; } } }
protected async override Task AddAsync(FarmingEntities db, CowViewModel model) { var cow = new Cow() { BreedId = model.BreedId, LineId = model.LineId, FamilyId = model.FamilyId, CategoryId = model.CategoryId, BloodTypeId = model.BloodTypeId, MotherId = model.MotherId, FatherId = model.FatherId, Porodnost = model.Porodnost.Value, Name = model.Name, BDay = model.BDay.Value, BPlace = model.BPlace, Weight = model.Weight.Value, Age = model.Age.Value, IsInHerd = model.IsInHerd.Value, }; db.Cows.Add(cow); await db.SaveChangesAsync(); model.Id = cow.Id; Models.Add(model); }
protected async override Task DeleteAsync(FarmingEntities db, GenderViewModel model) { var gender = await db.Genders.FindAsync(model.Id); if (gender != null) { db.Genders.Remove(gender); await db.SaveChangesAsync(); Models.Remove(model); } }
protected async override Task DeleteAsync(FarmingEntities db, MethodSluchkiViewModel model) { var methodSluchki = await db.MethodsSluchki.FindAsync(model.Id); if (methodSluchki != null) { db.MethodsSluchki.Remove(methodSluchki); await db.SaveChangesAsync(); Models.Remove(model); } }
protected async override Task DeleteAsync(FarmingEntities db, FamilyViewModel model) { var family = await db.Families.FindAsync(model.Id); if (family != null) { db.Families.Remove(family); await db.SaveChangesAsync(); Models.Remove(model); } }
protected async override Task DeleteAsync(FarmingEntities db, LineViewModel model) { var line = await db.Lines.FindAsync(model.Id); if (line != null) { db.Lines.Remove(line); await db.SaveChangesAsync(); Models.Remove(model); } }
protected async override Task DeleteAsync(FarmingEntities db, CowViewModel model) { var cow = await db.Cows.FindAsync(model.Id); if (cow != null) { db.Cows.Remove(cow); await db.SaveChangesAsync(); Models.Remove(model); } }
protected async override Task DeleteAsync(FarmingEntities db, ProductivityViewModel model) { var productivity = await db.Productivities.FindAsync(model.Id); if (productivity != null) { db.Productivities.Remove(productivity); await db.SaveChangesAsync(); Models.Remove(model); } }
protected async override Task DeleteAsync(FarmingEntities db, CategoryViewModel model) { var category = await db.Categories.FindAsync(model.Id); if (category != null) { db.Categories.Remove(category); await db.SaveChangesAsync(); Models.Remove(model); } }
protected async override Task DeleteAsync(FarmingEntities db, UserViewModel model) { var user = await db.Users.FindAsync(model.Login); if (user != null) { db.Users.Remove(user); await db.SaveChangesAsync(); Models.Remove(model); } }
protected async override Task DeleteAsync(FarmingEntities db, BloodTypeViewModel model) { var bType = await db.BloodTypes.FindAsync(model.Id); if (bType != null) { db.BloodTypes.Remove(bType); await db.SaveChangesAsync(); Models.Remove(model); } }
protected async override Task DeleteAsync(FarmingEntities db, BreedViewModel model) { var breed = await db.Breeds.FindAsync(model.Id); if (breed != null) { db.Breeds.Remove(breed); await db.SaveChangesAsync(); Models.Remove(model); } }
protected async override Task DeleteAsync(FarmingEntities db, RetirementViewModel model) { var retirement = await db.Retirements.FindAsync(model.Id); if (retirement != null) { db.Retirements.Remove(retirement); await db.SaveChangesAsync(); Models.Remove(model); } }
protected async override Task DeleteAsync(FarmingEntities db, ReproductionViewModel model) { var reproduction = await db.Reproductions.FindAsync(model.Id); if (reproduction != null) { db.Reproductions.Remove(reproduction); await db.SaveChangesAsync(); Models.Remove(model); } }
protected async override Task UpdateAsync(FarmingEntities db, CowViewModel model) { var cow = await db.Cows.FindAsync(model.Id); if (cow != null) { cow.BreedId = model.BreedId; cow.LineId = model.LineId; cow.FamilyId = model.FamilyId; cow.CategoryId = model.CategoryId; cow.BloodTypeId = model.BloodTypeId; cow.MotherId = model.MotherId; cow.FatherId = model.FatherId; cow.Porodnost = model.Porodnost.Value; cow.Name = model.Name; cow.BDay = model.BDay.Value; cow.BPlace = model.BPlace; cow.Weight = model.Weight.Value; cow.Age = model.Age.Value; cow.IsInHerd = model.IsInHerd.Value; await db.SaveChangesAsync(); var cowVm = Models.FirstOrDefault(c => c.Id == cow.Id); if (cowVm != null) { cowVm.BreedId = model.BreedId; cowVm.LineId = model.LineId; cowVm.FamilyId = model.FamilyId; cowVm.CategoryId = model.CategoryId; cowVm.BloodTypeId = model.BloodTypeId; cowVm.MotherId = model.MotherId; cowVm.FatherId = model.FatherId; cowVm.Porodnost = model.Porodnost.Value; cowVm.Name = model.Name; cowVm.BDay = model.BDay.Value; cowVm.BPlace = model.BPlace; cowVm.Weight = model.Weight.Value; cowVm.Age = model.Age.Value; cowVm.IsInHerd = model.IsInHerd.Value; cowVm.Breed = model.Breed; cowVm.Line = model.Line; cowVm.Family = model.Family; cowVm.Category = model.Category; cowVm.BloodType = model.BloodType; cowVm.Mother = model.Mother; cowVm.Father = model.Father; } } }
protected async override Task AddAsync(FarmingEntities db, GenderViewModel model) { var gender = new Gender() { Name = model.Name }; db.Genders.Add(gender); await db.SaveChangesAsync(); model.Id = gender.Id; Models.Add(model); }
protected async override Task AddAsync(FarmingEntities db, FamilyViewModel model) { var family = new Family() { Name = model.Name }; db.Families.Add(family); await db.SaveChangesAsync(); model.Id = family.Id; Models.Add(model); }
protected async override Task AddAsync(FarmingEntities db, MethodSluchkiViewModel model) { var methodSluchki = new MethodSluchki() { Name = model.Name }; db.MethodsSluchki.Add(methodSluchki); await db.SaveChangesAsync(); model.Id = methodSluchki.Id; Models.Add(model); }
protected async override Task AddAsync(FarmingEntities db, LineViewModel model) { var line = new Line() { Name = model.Name }; db.Lines.Add(line); await db.SaveChangesAsync(); model.Id = line.Id; Models.Add(model); }
protected async override Task AddAsync(FarmingEntities db, BreedViewModel model) { var newBType = new Breed() { Name = model.Name }; db.Breeds.Add(newBType); await db.SaveChangesAsync(); model.Id = newBType.Id; Models.Add(model); }
protected async override Task AddAsync(FarmingEntities db, BullViewModel model) { var bull = new Bull() { Location = model.Location, OtherId = model.OtherId }; db.Bulls.Add(bull); await db.SaveChangesAsync(); model.Id = bull.Id; Models.Add(model); }
protected async override Task AddAsync(FarmingEntities db, PriplodViewModel model) { var priplod = new Priplod() { CowId = model.CowId, GenderId = model.GenderId, Weight = model.Weight.Value }; db.Priplods.Add(priplod); await db.SaveChangesAsync(); model.Id = priplod.Id; Models.Add(model); }
protected async override Task AddAsync(FarmingEntities db, RetirementViewModel model) { var retirement = new Retirement() { CowId = model.CowId, Date = model.Date.Value, Reason = model.Reason }; db.Retirements.Add(retirement); await db.SaveChangesAsync(); model.Id = retirement.Id; Models.Add(model); }
protected async override Task UpdateAsync(FarmingEntities db, FamilyViewModel model) { var family = await db.Families.FindAsync(model.Id); if (family != null) { family.Name = model.Name; await db.SaveChangesAsync(); var familyVm = Models.FirstOrDefault(f => f.Id == family.Id); if (familyVm != null) { familyVm.Name = family.Name; } } }
protected async override Task UpdateAsync(FarmingEntities db, BloodTypeViewModel model) { var bType = await db.BloodTypes.FindAsync(model.Id); if (bType != null) { bType.Name = model.Name; await db.SaveChangesAsync(); var bTypeVm = Models.FirstOrDefault(t => t.Id == bType.Id); if (bTypeVm != null) { bTypeVm.Name = model.Name; } } }
protected async override Task UpdateAsync(FarmingEntities db, CategoryViewModel model) { var category = await db.Categories.FindAsync(model.Id); if (category != null) { category.Name = model.Name; await db.SaveChangesAsync(); var categoryVm = Models.FirstOrDefault(c => c.Id == category.Id); if (categoryVm != null) { categoryVm.Name = model.Name; } } }
protected async override Task UpdateAsync(FarmingEntities db, LineViewModel model) { var line = await db.Lines.FindAsync(model.Id); if (line != null) { line.Name = model.Name; await db.SaveChangesAsync(); var lineVm = Models.FirstOrDefault(l => l.Id == line.Id); if (lineVm != null) { lineVm.Name = model.Name; } } }
protected async override Task UpdateAsync(FarmingEntities db, BreedViewModel model) { var breed = await db.Breeds.FindAsync(model.Id); if (breed != null) { breed.Name = model.Name; await db.SaveChangesAsync(); var breedVm = Models.FirstOrDefault(b => b.Id == breed.Id); if (breedVm != null) { breedVm.Name = model.Name; } } }