public string CreateDealer(Dealer dealer) { try { if (dealer != null) { var res = _DbContext.Dealers.Where(x => x.Email == dealer.Email).FirstOrDefault(); if (res != null) { return("already"); } Database.Dealer entity = new Database.Dealer(); entity = AutoMapperConfig.DealerMapper.Map <Database.Dealer>(dealer); _DbContext.Dealers.Add(entity); _DbContext.SaveChanges(); return("created"); } return("null"); } catch (Exception ex) { return(ex.Message); } }
public bool IsActive(int DealerId) { Database.Dealer entity = new Database.Dealer(); if (entity.IsActive) { return(true); } return(false); }
public Dealers getDealer(int DealerId) { Database.Dealer entity = new Database.Dealer(); entity = dbcontext.Dealers.Find(DealerId); var config = new MapperConfiguration(cfg => cfg.CreateMap <Database.Dealer, Dealers>()); var mapper = new Mapper(config); Dealers dealer = mapper.Map <Dealers>(entity); return(dealer); }
public string DeleteDealer(int DealerId) { Database.Dealer entity = new Database.Dealer(); entity = dbcontext.Dealers.Find(DealerId); if (entity != null) { dbcontext.Dealers.Remove(entity); dbcontext.SaveChanges(); return("Successfully Deleted"); } return("Done"); }
public Dealer GetDealer(int id) { Dealer dealer; Database.Dealer entity = _DbContext.Dealers.Find(id); if (entity != null) { dealer = AutoMapperConfig.DealerMapper.Map <Dealer>(entity); } else { dealer = new Dealer(); } return(dealer); }
public string createDealer(DealerVM model) { if (model != null) { Database.Dealer dealer = new Database.Dealer(); dealer.Name = model.Name; dealer.Mobile = model.Mobile; dealer.Address = model.Address; //dealer.Locality = model.Locality; dealer.Zipcode = model.Zipcode; dealer.Email = model.Email; _dbContext.Dealers.Add(dealer); _dbContext.SaveChanges(); return(""); } return(""); }
public string CreateDealer(Dealers dealer) { try { if (dealer != null) { Database.Dealer entity = new Database.Dealer(); var config = new MapperConfiguration(cfg => cfg.CreateMap <Dealers, Database.Dealer>()); var mapper = new Mapper(config); entity = mapper.Map <Database.Dealer>(dealer); dbcontext.SaveChanges(); return("created"); } return("null"); } catch (Exception ex) { return(ex.Message); } }