public static ProductGroupWarehouseViewModel ToModel(this RWarehouse request, string venderName, bool isAdd) { if (request == null) { return(null); } return(new ProductGroupWarehouseViewModel { AddressDetail = request.AddressDetail, Code = request.Code, Name = request.Name, DistrictId = request.DistrictId, Email = request.Email, Id = request.Id, PhoneNumber = request.PhoneNumber, ProvinceId = request.ProvinceId, RoadId = request.RoadId, Status = request.Status, VillageId = request.VillageId, VendorId = request.VendorId, Description = request.Description, Type = request.Type, VendorName = venderName, IsAdd = isAdd, }); }
public static WarehouseViewModel ToModel(this RWarehouse request, string provinceName, string districtName, string villageName, string roadName) { if (request == null) { return(null); } return(new WarehouseViewModel { AddressDetail = request.AddressDetail, Code = request.Code, Name = request.Name, DistrictId = request.DistrictId, DistrictName = districtName, Email = request.Email, Id = request.Id, PhoneNumber = request.PhoneNumber, ProvinceId = request.ProvinceId, ProvinceName = provinceName, RoadId = request.RoadId, RoadName = roadName, Status = request.Status, VillageId = request.VillageId, VillageName = villageName, VendorId = request.VendorId, Description = request.Description, Type = request.Type, }); }
public async Task <ICommandResult> Handle(AddressSelectedCommand mesage) { try { var shard = await _shardingService.GetShardById(ShardGroup, mesage.ShardId); RCart rCart = await _cartService.GetFromDb(shard.ConnectionString, mesage.CartId); if (rCart == null) { throw new MessageException(ResourceKey.Cart_NotFound); } if (rCart.Version != mesage.Version) { throw new MessageException(ResourceKey.Cart_IsChanged); } Cart cart = new Cart(rCart); RWarehouse[] warehouses = new RWarehouse[0]; RWarehouse_Product_Mapping[] warehouseProductMappings = new RWarehouse_Product_Mapping[0]; WorkingTime[] logisticsWorkingTimes = new WorkingTime[0]; Holiday[] logisticsHolidayTimes = new Holiday[0]; //tinh ton kho var quantityChangedsCancel = cart.AddressSelectedCancel(); var quantityChanges = cart.AddressSelected(mesage, warehouses, warehouseProductMappings, logisticsWorkingTimes, logisticsHolidayTimes); await _eventSender.Notify(); ICommandResult result = new CommandResult() { Message = "", ObjectId = string.Empty, Status = CommandResult.StatusEnum.Sucess }; return(result); } catch (MessageException e) { e.Data["Param"] = mesage; ICommandResult result = new CommandResult() { Message = e.Message, Status = CommandResult.StatusEnum.Fail, ResourceName = e.ResourceName }; return(result); } catch (Exception e) { e.Data["Param"] = mesage; ICommandResult result = new CommandResult() { Message = e.Message, Status = CommandResult.StatusEnum.Fail }; return(result); } }
private bool GetShippingTimes(CartItem cartItem, RWarehouse warehouse, RWarehouse_Product_Mapping warehouseProductMapping, AddressSelectedCommand command, WorkingTime[] logisticsWorkingTimes, Holiday[] logisticsHolidayTimes) { if (warehouseProductMapping.PickupAndShippingTimeByWard.ContainsKey(command.WardId)) { cartItem.SetStatus(EnumDefine.CartStatusEnum.NotShippingSupport); return(false); } DateTime dtNow = Extensions.GetCurrentDateUtc(); DateTime shippingTime = dtNow; int i = -1; while (true) { i++; if (i > 10) { break; } shippingTime = shippingTime.AddDays(i); var dayOfWeek = shippingTime.DayOfWeek; WorkingTime workingTime = warehouse.WorkingTimes.FirstOrDefault(p => p.DayOfWeek == dayOfWeek); if (workingTime == null) { shippingTime = shippingTime.Date; continue; } // ReSharper disable once AccessToModifiedClosure Holiday holidayDay = warehouse.HolidayTimes.FirstOrDefault(p => p.Day.Date == shippingTime.Date); int pickupMinute = 0; var productShippingTimeConfig = warehouseProductMapping.PickupAndShippingTimeByWard[command.WardId]; if (holidayDay != null) { // ReSharper disable once AccessToModifiedClosure var holidayDayWorkingTimes = holidayDay.WorkingTimes.FirstOrDefault(p => shippingTime.Minute + productShippingTimeConfig.Item1 < p.Item2); if (holidayDayWorkingTimes == null) { shippingTime = shippingTime.Date; continue; } pickupMinute = holidayDayWorkingTimes.Item1; } else { pickupMinute = workingTime.Times[0].Item1; } cartItem.SetShippingTime(shippingTime.AddMinutes(pickupMinute), productShippingTimeConfig.Item2, logisticsWorkingTimes, logisticsHolidayTimes); return(true); } cartItem.SetStatus(EnumDefine.CartStatusEnum.IsVenderHoliday); return(false); }
public static WarehouseViewModel ToModel(this RWarehouse request, string provinceName, string districtName, string villageName, string roadName, string venderName) { if (request == null) { return(null); } var warehouse = request.ToModel(provinceName, districtName, villageName, roadName); if (warehouse != null) { warehouse.VendorName = venderName; } return(warehouse); }
public void WarehouseSelected(RWarehouse warehouse) { WarehouseId = warehouse.WarehouseId; SetStatus(EnumDefine.CartStatusEnum.EnoughInventory); }