public IActionResult AddWareHouseArea(string areaName, string areaCode, List <WareHouseAreaModel> ranksArrs) { try { var wareHouseArea = _wareHouseService.GetWareHouseAreaByName(areaName); if (wareHouseArea != null) { return(Error("已存在相同名称的区域")); } var model = new WareHouseArea { AreaCode = areaCode, AreaName = areaName, WhId = ranksArrs.Count() > 0 ? ranksArrs.OrderByDescending(r => r.Rank).FirstOrDefault().WareHouseId : 0, }; _wareHouseService.AddWareHouseArea(model); foreach (var item in ranksArrs) { var rank = new WareHouseAreaRanks { WhAId = model.Id, WhId = item.WareHouseId, Rank = item.Rank, }; _wareHouseService.AddWareHouseAreaRanks(rank); } return(Success()); } catch (Exception ex) { return(Error(ex.Message)); } }