コード例 #1
0
 public static Shipper MapToEditEntity(this ShipperEditModels model, Shipper entity)
 {
     entity.ShipperId   = model.ShipperId;
     entity.CompanyName = model.CompanyName;
     entity.Phone       = model.Phone;
     return(entity);
 }
コード例 #2
0
 public static Shipper MapToEditEntity(this ShipperEditModels model)
 {
     return(new Shipper
     {
         ShipperId = model.ShipperId,
         CompanyName = model.CompanyName,
         Phone = model.Phone
     });
 }
コード例 #3
0
ファイル: ShipperService.cs プロジェクト: dungthieu/Sales
        public ShipperEditModels CreateShipper(ShipperEditModels model, out string message)
        {
            var ship = _ShipperRepository.getshipper(model.ShipperId, model.CompanyName, model.Phone);

            if (ship != null)
            {
                message = Constant.ShipperIsExist;
                return(null);
            }
            var CreateShipper = _ShipperRepository.Insert(model.MapToEditEntity());

            UnitOfwork.SaveChanges();
            if (CreateShipper == null)
            {
                message = Constant.CreateFail;
                return(null);
            }
            message = Constant.CreateSuccess;
            return(CreateShipper.MapToEditModel());
        }
コード例 #4
0
ファイル: ShipperService.cs プロジェクト: dungthieu/Sales
        public bool UpdateShipper(ShipperEditModels model, out string message)
        {
            var shipperEntity = _ShipperRepository.GetById(model.ShipperId);

            if (shipperEntity != null)
            {
                var gr = _ShipperRepository.getshipper(model.ShipperId, model.CompanyName, model.Phone);
                if (gr != null)
                {
                    message = Constant.ShipperIsExist;
                    return(false);
                }
                shipperEntity = model.MapToEditEntity(shipperEntity);
                _ShipperRepository.Update(shipperEntity);
                UnitOfwork.SaveChanges();
                message = Constant.UpdateSuccess;
                return(true);
            }
            message = Constant.UpdateFail;
            return(false);
        }