示例#1
0
 public long Add(Seller seller)
 {
     seller.Id = 0;
     _context.Entry(seller).State = EntityState.Added;
     _context.SaveChanges();
     return(seller.Id);
 }
示例#2
0
 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);
 }
示例#3
0
 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;
     }
 }
示例#4
0
 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;
     }
 }
示例#5
0
 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);
 }
示例#6
0
        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));
        }
示例#8
0
        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
        }
示例#9
0
 public bool Update(OrderHeader entity, EntitiesDbContext context)
 {
     context.Entry(entity).State = EntityState.Modified;
     context.SaveChanges();
     return(true);
 }
示例#10
0
 public long Add(Safe safe, EntitiesDbContext context)
 {
     context.Entry(safe).State = EntityState.Added;
     context.SaveChanges();
     return(safe.Id);
 }
示例#11
0
 public long Add(Safe safe)
 {
     _context.Entry(safe).State = EntityState.Added;
     _context.SaveChanges();
     return(safe.Id);
 }
示例#12
0
 public void Update(TEntity entity)
 {
     _table.Attach(entity);
     _db.Entry(entity).State = EntityState.Modified;
 }