public ActionDetails CreateBrands(BrandBo brand) { try { if (brand.Image == null) { brand.Image = "no.jpg"; } Mapper.CreateMap <BrandBo, Brand>(); dba.Brands.Add(Mapper.Map <Brand>(brand)); dba.SaveChanges(); return(ResponseMessage.Success()); } catch (Exception ex) { return(ResponseMessage.Error(ex)); } }
public ActionDetails DeleteBrand(BrandBo brand) { try { var obj = dba.Brands.Where(p => p.BrandId == brand.BrandId && p.DomainId == brand.DomainId).FirstOrDefault(); if (obj == null) { throw new Exception("Brand canot be found"); } dba.Brands.Remove(obj); dba.SaveChanges(); return(ResponseMessage.Success()); } catch (Exception ex) { return(ResponseMessage.Error(ex)); } }
public ActionDetails UpdateBrands(BrandBo brand) { try { var obj = dba.Brands.Where(p => p.BrandId == brand.BrandId && p.DomainId == brand.DomainId).FirstOrDefault(); if (obj == null) { throw new Exception("Brand canot be found"); } obj.BrandDiscription = brand.BrandDiscription; obj.BrandName = brand.BrandName; obj.Enable = brand.Enable; obj.Image = brand.Image; obj.Seo = brand.Seo; dba.SaveChanges(); return(ResponseMessage.Success()); } catch (Exception ex) { return(ResponseMessage.Error(ex)); } }