Пример #1
0
        public void saveOptionsFactor(OptionsFactor objOptionsFactor, bool toDelete = false)
        {
            if (objOptionsFactor.Id != 0)
            {
                var existingObj = _context.OptionsFactors.Where(x => x.Id == objOptionsFactor.Id && x.IsActive == true).FirstOrDefault();
                if (existingObj != null)
                {
                    if (toDelete)
                    {
                        existingObj.IsActive = false;
                    }
                    else
                    {
                        existingObj.ManufacturerId = objOptionsFactor.ManufacturerId;
                        existingObj.StateId        = objOptionsFactor.StateId;
                        existingObj.OptionsTypeId  = objOptionsFactor.OptionsTypeId;
                        existingObj.Rate           = objOptionsFactor.Rate;
                        existingObj.Factor         = objOptionsFactor.Factor;
                    }

                    _context.Entry(existingObj).State = System.Data.Entity.EntityState.Modified;
                    _context.SaveChanges();
                }
            }
            else
            {
                objOptionsFactor.IsActive  = true;
                objOptionsFactor.CreatedOn = DateTime.Now;
                objOptionsFactor.CreatedBy = "admin";
                _context.OptionsFactors.Add(objOptionsFactor);
                _context.SaveChanges();
            }
        }
Пример #2
0
 public void saveManufacturer(Manufacturer manufacturerObj, bool toDelete = false)
 {
     if (manufacturerObj.Id != 0)
     {
         var existingObj = _context.Manufacturers.Where(x => x.Id == manufacturerObj.Id).SingleOrDefault();
         if (existingObj != null)
         {
             if (toDelete)
             {
                 existingObj.isActive = false;
             }
             else
             {
                 existingObj.Name = manufacturerObj.Name;
             }
             _context.Entry(existingObj).State = System.Data.Entity.EntityState.Modified;
             _context.SaveChanges();
         }
     }
     else
     {
         manufacturerObj.CreatedBy = "admin";
         manufacturerObj.CreatedOn = DateTime.Now;
         manufacturerObj.isActive  = true;
         _context.Manufacturers.Add(manufacturerObj);
         _context.SaveChanges();
     }
 }