Exemplo n.º 1
0
 public SellerDTO ReadById(int id)
 {
     using (InfoSellersEntities data = new InfoSellersEntities())
     {
         var entity = data.Seller.Find(id);
         if (entity != null)
         {
             return(new SellerDTO()
             {
                 ID = entity.ID,
                 FullName = entity.FullName,
                 Active = entity.Active,
                 CurrentCommission = entity.CurrentCommission,
                 Nit = entity.Nit,
                 PenaltyPercentage = entity.PenaltyPercentage,
                 Phone = entity.Phone,
                 RolID = entity.RolID,
                 SellerAddress = entity.SellerAddress
             });
         }
         else
         {
             return(null);
         }
     }
 }
Exemplo n.º 2
0
 public void Delete(int id)
 {
     using (InfoSellersEntities data = new InfoSellersEntities())
     {
         data.Seller.Remove(data.Seller.Find(id));
         data.SaveChanges();
     }
 }
Exemplo n.º 3
0
 public SellerDTO Update(SellerDTO entity)
 {
     using (InfoSellersEntities data = new InfoSellersEntities())
     {
         var d = data.Seller.Find(entity.ID);
         d.Nit               = entity.Nit;
         d.FullName          = entity.FullName;
         d.PenaltyPercentage = entity.PenaltyPercentage;
         d.Phone             = entity.Phone;
         d.RolID             = entity.RolID;
         d.SellerAddress     = entity.SellerAddress;
         d.Active            = entity.Active;
         d.CurrentCommission = entity.CurrentCommission;
         data.SaveChanges();
     }
     return(entity);
 }
Exemplo n.º 4
0
 public List <SellerDTO> Read()
 {
     using (InfoSellersEntities data = new InfoSellersEntities())
     {
         return(data.Seller.Select(q => new SellerDTO()
         {
             ID = q.ID,
             FullName = q.FullName,
             Active = q.Active,
             CurrentCommission = q.CurrentCommission,
             Nit = q.Nit,
             PenaltyPercentage = q.PenaltyPercentage,
             Phone = q.Phone,
             RolID = q.RolID,
             SellerAddress = q.SellerAddress
         }).ToList());
     }
 }
Exemplo n.º 5
0
 public SellerDTO Create(SellerDTO entity)
 {
     using (InfoSellersEntities data = new InfoSellersEntities())
     {
         var newSeller = new Seller()
         {
             Nit               = entity.Nit,
             Active            = entity.Active,
             CurrentCommission = entity.CurrentCommission,
             FullName          = entity.FullName,
             PenaltyPercentage = entity.PenaltyPercentage,
             Phone             = entity.Phone,
             RolID             = entity.RolID,
             SellerAddress     = entity.SellerAddress
         };
         data.Seller.Add(newSeller);
         data.SaveChanges();
         entity.ID = newSeller.ID;
     }
     return(entity);
 }