public void Update(T model) { if (model != null) { masterContext.Entry(model).State = EntityState.Modified; } }
public async Task <IActionResult> PutProductTable(int id, Product product) { if (id != product.Id) { return(BadRequest()); } _context.Entry(product).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProductTableExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutCourse(int id, Course course) { if (id != course.CourseId) { return(BadRequest()); } _context.Entry(course).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CourseExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public void Update(TEntity entityToUpdate) { dbSet.Attach(entityToUpdate); _context.Entry(entityToUpdate).State = EntityState.Modified; _context.SaveChanges();//idem sus }
public async Task <IActionResult> PutAdminDetails(int id, AdminDetails adminDetails) { if (id != adminDetails.Id) { return(BadRequest()); } _context.Entry(adminDetails).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AdminDetailsExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutPersonalTrainers(int id, PersonalTrainers personalTrainers) { if (id != personalTrainers.Id) { return(BadRequest()); } _context.Entry(personalTrainers).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PersonalTrainersExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutCustomerIdentification(int id, CustomerIdentification customerIdentification) { if (id != customerIdentification.CustomerUniqueId) { return(BadRequest()); } _context.Entry(customerIdentification).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CustomerIdentificationExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public ActionResult DynamicAddOrEdit(owl_DynamicPage model) { try { if (model.Id == 0) { MasterContext dynamicadd = new MasterContext(); owl_DynamicPage dynamicPages = new owl_DynamicPage() { Name = model.Name, Info = model.Info, }; dynamicadd.DynamicPage.Add(dynamicPages); dynamicadd.SaveChanges(); ViewBag.message = "Dynamic Sayfa Eklendi"; ModelState.Clear(); return(Redirect("/Dynamic/DynamicList")); } else { MasterContext synamicadd = new MasterContext(); synamicadd.Entry(model).State = System.Data.Entity.EntityState.Modified; synamicadd.SaveChanges(); return(Redirect("/Dynamic/DynamicList")); } } catch (Exception) { throw; } }
public void Update(Punct4 punct) { using (var context = new MasterContext()) { context.Entry(punct).State = EntityState.Modified; context.SaveChanges(); } }
public void DeleteClient(Punct4 punct) { using (var context = new MasterContext()) { context.Entry(punct).State = EntityState.Deleted; context.SaveChanges(); } }
public ActionResult AddOrEdit(News model) { try { if (model.ImageFile.ContentLength > 0) { string _filename = Path.GetFileName(model.ImageFile.FileName); string _path = Path.Combine(Server.MapPath("/assets/Uploads/"), _filename); model.ImageFile.SaveAs(_path); model.Image = _filename; } if (model.Id == 0) { MasterContext newsadd = new MasterContext(); News haber = new News() { Name = model.Name, Image = model.Image, Info = model.Info, ShortDescription = model.ShortDescription, }; newsadd.News.Add(haber); newsadd.SaveChanges(); ViewBag.message = "Yeni Haber Eklendi"; ModelState.Clear(); return(Redirect("/Media/NewsList")); } else { MasterContext newsadd = new MasterContext(); newsadd.Entry(model).State = System.Data.Entity.EntityState.Modified; newsadd.SaveChanges(); return(Redirect("/Media/NewsList")); } } catch (Exception) { throw; } }
public ActionResult SliderAddOrEdit(owl_HomeSlider model) { try { if (model.ImageFile.ContentLength > 0) { string _filename = Path.GetFileName(model.ImageFile.FileName); string _path = Path.Combine(Server.MapPath("/assets/Uploads/"), _filename); model.ImageFile.SaveAs(_path); model.Image = _filename; } if (model.Id == 0) { MasterContext slideradd = new MasterContext(); owl_HomeSlider homeSlider = new owl_HomeSlider() { SliderName = model.SliderName, SliderInfo = model.SliderInfo, Image = model.Image, }; slideradd.HomeSlider.Add(homeSlider); slideradd.SaveChanges(); ViewBag.message = "Yeni Slider Eklendi"; ModelState.Clear(); return(Redirect("/Home/SlidersList")); } else { MasterContext slideradd = new MasterContext(); slideradd.Entry(model).State = System.Data.Entity.EntityState.Modified; slideradd.SaveChanges(); return(Redirect("/Home/SlidersList")); } } catch (Exception) { throw; } }
public ActionResult PhotosAddOrEdit(owl_PhotoGallery model) { try { if (model.ImageFile.ContentLength > 0) { string _filename = Path.GetFileName(model.ImageFile.FileName); string _path = Path.Combine(Server.MapPath("/assets/Uploads/"), _filename); model.ImageFile.SaveAs(_path); model.Image = _filename; } if (model.Id == 0) { MasterContext photoGalleryadd = new MasterContext(); owl_PhotoGallery photoGallety = new owl_PhotoGallery() { Name = model.Name, Info = model.Info, Image = model.Image, }; photoGalleryadd.PhotoGallery.Add(photoGallety); photoGalleryadd.SaveChanges(); ViewBag.message = "Resim Eklendi Eklendi"; ModelState.Clear(); return(Redirect("/Media/PhotosList")); } else { MasterContext photoGalleryadd = new MasterContext(); photoGalleryadd.Entry(model).State = System.Data.Entity.EntityState.Modified; photoGalleryadd.SaveChanges(); return(Redirect("/Media/PhotosList")); } } catch (Exception) { throw; } }
public ActionResult Product_GroupAddOrEdit(HotProduct_Group model) { try { //if (model.ImageFile.ContentLength > 0) //{ // string _filename = Path.GetFileName(model.ImageFile.FileName); // string _path = Path.Combine(Server.MapPath("/assets/Uploads/"), _filename); // model.ImageFile.SaveAs(_path); // model.Image = _filename; //} if (model.Id == 0) { MasterContext Product_GroupAdd = new MasterContext(); HotProduct_Group hotProduct_group = new HotProduct_Group() { Code = model.Code, Name = model.Name, Info = model.Info, }; Product_GroupAdd.Product_Gruop.Add(hotProduct_group); Product_GroupAdd.SaveChanges(); ViewBag.message = "Yeni Haber Eklendi"; ModelState.Clear(); return(Redirect("/Product/Product_Group_List")); } else { MasterContext Product_Group = new MasterContext(); Product_Group.Entry(model).State = System.Data.Entity.EntityState.Modified; Product_Group.SaveChanges(); return(Redirect("/Product/Product_Group_List")); } } catch (Exception) { throw; } }
public bool Update(Product product) { _context.Entry(product).State = EntityState.Modified; try { _context.SaveChanges(); return(true); } catch (DbUpdateConcurrencyException) { if (product.Id.Equals(-1)) { throw new Exception("No product with that id"); } else { throw; } } }
public bool saveemoloyeedata(EmployeeDto obj) { bool result = false; try { var emp = Mapper.Convert <Employee, EmployeeDto>(obj); MasterContext.Entry(emp).State = EntityState.Added; MasterContext.Employee.Add(emp); MasterContext.SaveChanges(); result = true; } catch (Exception ex) { result = false; } return(result); }
public bool Update(Operations operations) { _context.Entry(operations).State = EntityState.Modified; try { _context.SaveChanges(); return(true); } catch (DbUpdateConcurrencyException) { if (operations.Id.Equals(-1)) { throw new Exception("No Operations with that id"); } else { throw; } } }
public bool Update(ManufacturingPlan manufacturingPlan) { _context.Entry(manufacturingPlan).State = EntityState.Modified; try { _context.SaveChanges(); return(true); } catch (DbUpdateConcurrencyException) { if (manufacturingPlan.Id.Equals(-1)) { throw new Exception("No ManufacturingPlan with that id"); } else { throw; } } }
public ActionResult ContactAddOrEdit(owl_ContactInformations model) { try { if (model.Id == 0) { MasterContext contactadd = new MasterContext(); owl_ContactInformations contactInformations = new owl_ContactInformations() { Info = model.Info, Address = model.Address, Phone_Name = model.Phone_Name, Phone_No = model.Phone_No, Fax = model.Fax, Mail_Name = model.Mail_Name, Mail_Address = model.Mail_Address, }; contactadd.Contact.Add(contactInformations); contactadd.SaveChanges(); ViewBag.message = "İletişim Bilgisi Eklendi"; ModelState.Clear(); return(Redirect("/Contact/ContactList")); } else { MasterContext contactadd = new MasterContext(); contactadd.Entry(model).State = System.Data.Entity.EntityState.Modified; contactadd.SaveChanges(); return(Redirect("/Contact/ContactList")); } } catch (Exception) { throw; } }
public ActionResult Product_AddOrEdit(HotProduct model) { try { if (model.Id == 0) { MasterContext Product_Add = new MasterContext(); HotProduct hotProduct = new HotProduct() { Code = model.Code, Name = model.Name, Stok_No = model.Stok_No, Fiyat_No = model.Fiyat_No, Adet_No = model.Adet_No, Info = model.Info, rlt_Product_Group_Id = model.rlt_Product_Group_Id, }; Product_Add.Product.Add(hotProduct); Product_Add.SaveChanges(); ViewBag.message = "Yeni Ürün Eklendi"; ModelState.Clear(); return(Redirect("/Product/Product_List")); } else { MasterContext Product = new MasterContext(); Product.Entry(model).State = System.Data.Entity.EntityState.Modified; Product.SaveChanges(); return(Redirect("/Product/Product_List")); } } catch (Exception) { throw; } }
public ActionResult AccountAddOrEdit(owl_Account model) { try { if (model.Id == 0) { MasterContext accountadd = new MasterContext(); owl_Account account = new owl_Account() { Name = model.Name, Surname = model.Surname, Email = model.Email, UserName = model.UserName, Password = model.Password, }; accountadd.Account.Add(account); accountadd.SaveChanges(); ViewBag.message = "Kullanıcı Bilgisi Eklendi"; ModelState.Clear(); return(Redirect("/Account/AccountList")); } else { MasterContext accountadd = new MasterContext(); accountadd.Entry(model).State = System.Data.Entity.EntityState.Modified; accountadd.SaveChanges(); return(Redirect("/Account/AccountList")); } } catch (Exception) { throw; } }
public void Update(T entity) { context.Entry(entity).State = EntityState.Modified; context.Set <T>().Update(entity); }
public void Update(T entityToUpdate) { _context.Entry(entityToUpdate).State = System.Data.EntityState.Modified; _context.SaveChanges(); }