public ItemBrand Put(ItemBrand item) { try { var identity = User.Identity as ClaimsIdentity; int compid = 0, userid = 0; foreach (Claim claim in identity.Claims) { if (claim.Type == "compid") { compid = int.Parse(claim.Value); } if (claim.Type == "userid") { userid = int.Parse(claim.Value); } } logger.Info("User ID : {0} , Company Id : {1}", compid, userid); return(context.PutItemBrand(item)); } catch { return(null); } }
public ItemBrand SaveBrand(ItemBrand brand) { if (brand.Id <= 0) { _brandRepo.Insert(brand); } else { _brandRepo.Update(brand); } return(brand); }
public JsonResult deleteItemBrand(ItemBrand ItemBrand) { try { new hdlItemBrand().delete(ItemBrand); } catch (Exception ex) { Response.StatusCode = 500; Content(JsonConvert.SerializeObject(new { error = ex.Message })); } return(getAllItemBrandCompany(ItemBrand.CompanyCode)); }
public JsonResult saveItemBrand(ItemBrand ItemBrand, int companyId) { try { new hdlItemBrand().save(ItemBrand, Convert.ToString(Session["User"]), companyId); } catch (Exception ex) { Response.StatusCode = 500; Content(JsonConvert.SerializeObject(new { error = ex.Message })); } return(getAllItemBrandCompany(ItemBrand.CompanyCode)); }
public ItemBrand add(ItemBrand item) { logger.Info("start ItemBrand: "); try { var identity = User.Identity as ClaimsIdentity; int compid = 0, userid = 0; // Access claims foreach (Claim claim in identity.Claims) { if (claim.Type == "compid") { compid = int.Parse(claim.Value); } if (claim.Type == "userid") { userid = int.Parse(claim.Value); } } item.CompanyId = compid; if (item == null) { throw new ArgumentNullException("item"); } logger.Info("User ID : {0} , Company Id : {1}", compid, userid); context.AddItemBrand(item); logger.Info("End ItemBrand: "); return(item); } catch (Exception ex) { logger.Error("Error in AddItemBrand " + ex.Message); logger.Info("End AddItemBrand: "); return(null); } }
public void delete(ItemBrand ItemBrand) { try { var context = new SmsMisDB(); //context.ItemBrand.Attach(ItemBrand); var entry = context.Entry(ItemBrand); if (entry != null) { entry.State = EntityState.Deleted; context.SaveChanges(); } } catch (System.Data.Entity.Validation.DbEntityValidationException ex) { //throw SmsMis.Models.Console.Common.ExceptionTranslater.translate(ex); throw ex; } catch (Exception ex) { //throw SmsMis.Models.Console.Common.ExceptionTranslater.translate(ex); throw ex; } }
public void save(ItemBrand ItemBrand, string userId, int CompanyCode) { try { using (var context = new SmsMisDB()) { var entry = context.Entry(ItemBrand); if (entry != null) { ItemBrand.AddDateTime = DateTime.Now; ItemBrand.AddByUserId = userId; if (ItemBrand.BrandCode == 0) { ItemBrand.BrandCode = Functions.getNextPk("ItemBrand", "ItemBrand.BrandCode", " WHERE ItemBrand.CompanyCode = " + ItemBrand.CompanyCode); entry.State = EntityState.Added; } else { entry.State = EntityState.Modified; } context.SaveChanges(); } } } catch (System.Data.Entity.Validation.DbEntityValidationException ex) { //throw ex; } catch (Exception ex) { // throw ex; } }