示例#1
0
        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);
            }
        }
示例#2
0
        public bool IsActive(int DealerId)
        {
            Database.Dealer entity = new Database.Dealer();

            if (entity.IsActive)
            {
                return(true);
            }
            return(false);
        }
示例#3
0
        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);
        }
示例#4
0
        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");
        }
示例#5
0
        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("");
 }
示例#7
0
        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);
            }
        }