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 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)); }