示例#1
0
        public ActionResult CreateShipper([FromBody] CreateShipperVM shipper)
        {
            var result = _shipperService.GetShippers(s => s.Phone == shipper.Phone);

            if (result.Count() > 0)
            {
                return(BadRequest("Phone Number Has Been Exist"));
            }
            var _Account = _shipperService.GetShippers(s => s.AccountId == shipper.AccountId);

            if (!_Account.Any())
            {
                var     newUser_Id = Guid.NewGuid();
                Account newAccount = new Account();
                newAccount.User_Id = newUser_Id.ToString();
                _accountService.CreateAccount(newAccount);
                _accountService.Save();
                Shipper newShipper = shipper.Adapt <Shipper>();
                newShipper.IsDelete  = false;
                newShipper.AccountId = newAccount.Id;
                _shipperService.CreateShipper(newShipper);
            }
            else
            {
                Shipper newShipper = shipper.Adapt <Shipper>();
                newShipper.IsDelete  = false;
                newShipper.AccountId = _Account.FirstOrDefault().Id;
                _shipperService.CreateShipper(newShipper);
            }
            _shipperService.Save();
            _hub.Clients.All.SendAsync("transferchartdata", "Hello");
            return(Ok(201));
        }
        public JsonResult Create(ShipperDetailView vm)
        {
            CreateShipperRequest request = new CreateShipperRequest();

            request.CompanyName = vm.CompanyName;
            request.Phone       = vm.Phone;
            CreateShipperResponse response = _shipperService.CreateShipper(request);

            return(Json(response));
        }
示例#3
0
        public ActionResult CreateShipper([FromBody] CreateShipperVM shipper)
        {
            var result = _shipperService.GetShippers(s => s.Phone == shipper.Phone);

            if (result.Count() > 0)
            {
                return(BadRequest("Phone Number Has Been Exist"));
            }
            Shipper newShipper = shipper.Adapt <Shipper>();

            newShipper.IsDelete = false;
            _shipperService.CreateShipper(newShipper);
            _shipperService.Save();
            return(Ok(200));
        }
示例#4
0
        public async Task <ActionResult <ShipperAPIModel> > CreateShipper(ShipperAPIModel shipper)
        {
            var validator        = new ShipperValidator();
            var validationResult = await validator.ValidateAsync(shipper);

            if (!validationResult.IsValid)
            {
                return(BadRequest(validationResult.Errors));
            }

            var shippers        = _mapper.Map <ShipperAPIModel, Shippers>(shipper);
            var shipperAPIModel = await _shipperService.CreateShipper(shippers);

            return(Ok(shipperAPIModel));
        }
示例#5
0
 public void Post(ShipperViewModel shipper)
 {
     _shipperService.CreateShipper(shipper);
 }