public long Add(Seller seller) { seller.Id = 0; _context.Entry(seller).State = EntityState.Added; _context.SaveChanges(); return(seller.Id); }
public bool Update(PurechasesHeader purechasesHeader) { _context.Entry(purechasesHeader).State = EntityState.Modified; _context.SaveChanges(); DeletePurchaseDetails(purechasesHeader.Id); SetPurechasesHeaderId(purechasesHeader.Id, purechasesHeader.PurechasesDetialsList); AddPurechasesDetials(purechasesHeader.PurechasesDetialsList, _context); _safeOperationsRepo.UpdateByHeaderId(purechasesHeader.Id, purechasesHeader.Total, AccountTypesEnum.Clients); return(true); }
public bool Add(Role role) { try { context.Entry(role).State = EntityState.Added; context.SaveChanges(); return(true); } catch (Exception ex) { System.IO.File.WriteAllText(@"e:\errorLog.txt", ex.Message); throw ex; } }
public long Add(Farmer farmer) { try { _context.Entry(farmer).State = EntityState.Added; _context.SaveChanges(); return(farmer.Id); } catch (Exception ex) { System.IO.File.WriteAllText(@"e:\errorLog.txt", ex.Message); throw ex; } }
public bool Add(PurechasesHeader purechasesHeader, EntitiesDbContext context) { context.Entry(purechasesHeader).State = EntityState.Added; context.SaveChanges(); SetPurechasesHeaderId(purechasesHeader.Id, purechasesHeader.PurechasesDetialsList); AddPurechasesDetials(purechasesHeader.PurechasesDetialsList, context); return(true); }
public bool Add(UserDTO userDTO) { User user = Map(userDTO); context.Entry(user).State = EntityState.Added; var result = context.SaveChanges(); if (result > 0) { SaveProfileImage(user.ImageUrl, userDTO.ImageBase64); return(true); } return(false); }
public ActionResult Edit([Bind(Include = "EntityGuid,EntityName,Description")] EntityEditViewModel entityEditViewModel) { if (ModelState.IsValid) { Entity entity = db.Entities.Find(entityEditViewModel.EntityGuid); entity.EntityName = entityEditViewModel.EntityName; entity.Description = entityEditViewModel.Description; entity.DateModified = DateTime.Now; entity.UserModifiedID = Auxiliaries.GetUserId(User); db.Entry(entity).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(entityEditViewModel)); }
public SalesinvoicesHeader Add(SalesinvoicesHeader salesinvoicesHeader, long orderHeaderId, EntitiesDbContext context) { //To-Do //Check if Seller has at least one salesinvoice at this day or no SalesinvoicesHeader exsistedSalesHeader = GetSalesinvoiceHeaderByDateAndSellerId(salesinvoicesHeader.SalesinvoicesDate, salesinvoicesHeader.SellerId, context); if (exsistedSalesHeader == null)//It is the first salesinvoice to this Seller in this day { context.Entry(salesinvoicesHeader).State = EntityState.Added; context.SaveChanges(); } if (salesinvoicesHeader.Id == 0) { salesinvoicesHeader.Id = exsistedSalesHeader.Id; } SetSalesinvoicesHeaderId(salesinvoicesHeader, salesinvoicesHeader.SalesinvoicesDetialsList); //Set SalesinvoiceHeaderId AddSalesinvoicesDetials(salesinvoicesHeader.SalesinvoicesDetialsList, context); //Add SalesinvoiceDetails return(UpdateSalesinvoiceTotal(salesinvoicesHeader.SalesinvoicesDetialsList, context)); //Return updated salesinvoiceHeader }
public bool Update(OrderHeader entity, EntitiesDbContext context) { context.Entry(entity).State = EntityState.Modified; context.SaveChanges(); return(true); }
public long Add(Safe safe, EntitiesDbContext context) { context.Entry(safe).State = EntityState.Added; context.SaveChanges(); return(safe.Id); }
public long Add(Safe safe) { _context.Entry(safe).State = EntityState.Added; _context.SaveChanges(); return(safe.Id); }
public void Update(TEntity entity) { _table.Attach(entity); _db.Entry(entity).State = EntityState.Modified; }