public static M.Supplier ToSupplier(this AddSupplierModel model, M.Supplier supplier) { supplier.Name = model.Name; supplier.Tel = model.Tel; supplier.Address = model.Address; supplier.BusinessTime = new M.BusinessTime(model.BusinessTimeStart.ToTime(), model.BusinessTimeEnd.ToTime()); supplier.Coordinates = new M.Coordinates(model.CoordinatesLongitude, model.CoordinatesLatitude); supplier.DeliveryTime = NullHelper.IfNull(model.DeliveryTime, new DeliveryTime[0]).Select(m => m.ToDeliveryTime()).ToArray(); return(supplier); }
private static dynamic InsertAndUpdateData(Supplier item) { var data = new { Id = item.Id, Name = item.Name, Address = item.Address, Tel = item.Tel, CoordnateLongitude = NullHelper.IfNull(item.Coordinates, "", m => m.Longitude), CoordnateLatitude = NullHelper.IfNull(item.Coordinates, "", m => m.Latitude), BusinesstimeStart = NullHelper.IfNull(item.BusinessTime, "", m => NullHelper.IfNull(m.Start, "", t => t.ToString())), BusinesstimeEnd = NullHelper.IfNull(item.BusinessTime, "", m => NullHelper.IfNull(m.End, "", t => t.ToString())), DeliveryTime = NullHelper.IfNull(item.DeliveryTime, "", m => string.Join("|", m.Select(t => t.Start + "-" + t.End).ToArray())), CreateDate = item.CreateDate, BusinessStatus = item.BusinessStatus }; return(data); }