示例#1
0
 public bool SavePackingType(PackingTypeModel model)
 {
     try
     {
         PackingTypeMaster master = new PackingTypeMaster()
         {
             name     = model.name,
             IsActive = true,
         };
         if (!CheckIfNameExists(model.name))
         {
             _tRSEntities4.PackingTypeMasters.Add(master);
             _tRSEntities4.SaveChanges();
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
示例#2
0
 public bool UpdatePackingType(PackingTypeModel model)
 {
     try
     {
         var check = _tRSEntities4.PackingTypeMasters.Where(x => x.id == model.id && x.IsActive == true).FirstOrDefault();
         if (check != null)
         {
             check.name = model.name;
             //check.isActive = model.isActive;
             _tRSEntities4.SaveChanges();
             return(true);
         }
         return(false);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
示例#3
0
 public PackingTypeModel GetPackingType(int id)
 {
     try
     {
         var check = _tRSEntities4.PackingTypeMasters.Where(x => x.id == id && x.IsActive == true).FirstOrDefault();
         if (check != null)
         {
             PackingTypeModel commodity = new PackingTypeModel();
             commodity.id   = check.id;
             commodity.name = check.name;
             check.IsActive = (bool)commodity.IsActive;
             return(commodity);
         }
         else
         {
             return(null);
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
示例#4
0
 public List <PackingTypeModel> GetPackingTypes()
 {
     try
     {
         List <PackingTypeModel> models = new List <PackingTypeModel>();
         var data = _tRSEntities4.PackingTypeMasters.Where(x => x.IsActive == true).ToList();
         foreach (var item in data)
         {
             PackingTypeModel db = new PackingTypeModel
             {
                 id       = item.id,
                 name     = item.name,
                 IsActive = (bool)item.IsActive,
             };
             models.Add(db);
         }
         return(models);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
        public IHttpActionResult UpdatePackingType(PackingTypeModel model)
        {
            var data = packingType.UpdatePackingType(model);

            return(Ok(data));
        }