public ActionResult CreateOrEditDeliveryOrder() { DeliveryOrderResponse _response = new DeliveryOrderResponse(); if (Request.QueryString["id"] != null) { var request = new DeliveryOrderRequest { Data = new DeliveryOrderModel { Id = long.Parse(Request.QueryString["id"].ToString()) } }; DeliveryOrderResponse resp = new DeliveryOrderHandler(_unitOfWork).GetDetail(request); DeliveryOrderModel _model = resp.Entity; ViewBag.Response = _response; return(View(_model)); } else { ViewBag.Response = _response; ViewBag.ActionType = ClinicEnums.Action.Add; return(View()); } }
public ActionResult GetDeliveryOrderData() { var _draw = Request.Form.GetValues("draw").FirstOrDefault(); var _start = Request.Form.GetValues("start").FirstOrDefault(); var _length = Request.Form.GetValues("length").FirstOrDefault(); var _sortColumn = Request.Form.GetValues("columns[" + Request.Form.GetValues("order[0][column]").FirstOrDefault() + "][name]").FirstOrDefault(); var _sortColumnDir = Request.Form.GetValues("order[0][dir]").FirstOrDefault(); var _searchValue = Request.Form.GetValues("search[value]").FirstOrDefault(); int _pageSize = _length != null?Convert.ToInt32(_length) : 0; int _skip = _start != null?Convert.ToInt32(_start) : 0; var request = new DeliveryOrderRequest { Draw = _draw, SearchValue = _searchValue, SortColumn = _sortColumn, SortColumnDir = _sortColumnDir, PageSize = _pageSize, Skip = _skip }; var response = new DeliveryOrderHandler(_unitOfWork).GetListData(request); return(Json(new { data = response.Data, recordsFiltered = response.RecordsFiltered, recordsTotal = response.RecordsTotal, draw = response.Draw }, JsonRequestBehavior.AllowGet)); }
public void Create(PurchaseOrderResponse _response) { var searchPredicate = PredicateBuilder.New <Data.DataRepository.DeliveryOrder>(true); _response.Entity.approve = null; _response.Entity.approveby = null; var request = new DeliveryOrderRequest { Data = Mapper.Map <PurchaseOrderModel, DeliveryOrderModel>(_response.Entity) }; request.Data.dodate = DateTime.Now; request.Data.poid = Convert.ToInt32(_response.Entity.Id); request.Data.Id = 0; var lastponumber = _unitOfWork.DeliveryOrderRepository.Get(searchPredicate, orderBy: a => a.OrderByDescending(x => x.CreatedDate)).Select(a => a.donumber).FirstOrDefault(); DateTime?getmonth = _unitOfWork.DeliveryOrderRepository.Get(searchPredicate, orderBy: a => a.OrderByDescending(x => x.CreatedDate)).Select(a => a.dodate).FirstOrDefault(); DateTime?month = getmonth != null ? getmonth : DateTime.Now; string ponumber = lastponumber != null?GeneralHandler.stringincrement(lastponumber, Convert.ToDateTime(month)) : "00001"; request.Data.donumber = "DO" + _response.Entity.Account.Organization + DateTime.Now.Year + DateTime.Now.Month + ponumber; request.Data.Account = _response.Entity.Account; DeliveryOrderResponse deliveryorderresponse = new DeliveryOrderResponse(); new DeliveryOrderValidator(_unitOfWork).Validate(request, out deliveryorderresponse); if (_response.Entity.PurchaseOrderDetails != null) { int i = 0; foreach (var item in _response.Entity.PurchaseOrderDetails) { var deliveryorderdetailrequest = new DeliveryOrderDetailRequest { Data = Mapper.Map <PurchaseOrderDetailModel, DeliveryOrderDetailModel>(item) }; deliveryorderdetailrequest.Data.DeliveryOderId = Convert.ToInt32(deliveryorderresponse.Entity.Id); deliveryorderdetailrequest.Data.Account = _response.Entity.Account; deliveryorderdetailrequest.Data.Id = 0; // var requestnamabarang = new ProductRequest { Data = new ProductModel { Id = Convert.ToInt32(item.ProductId) } }; ProductResponse namabarang = new ProductHandler(_unitOfWork).GetDetail(requestnamabarang); deliveryorderdetailrequest.Data.namabarang = namabarang.Entity.Name; DeliveryOrderDetailResponse _deliveryorderdetailresponse = new DeliveryOrderDetailResponse(); new DeliveryOrderDetailValidator(_unitOfWork).Validate(deliveryorderdetailrequest, out _deliveryorderdetailresponse); i++; } } }
public ActionResult ReceivedOrder(int id) { DeliveryOrderResponse _response = new DeliveryOrderResponse(); var request = new DeliveryOrderRequest { Data = new DeliveryOrderModel { Id = id } }; DeliveryOrderResponse resp = new DeliveryOrderHandler(_unitOfWork).GetDetail(request); resp.Entity.Account = (AccountModel)Session["UserLogon"]; resp.Entity.Recived = 1; resp.Entity.approve = 1; var receiveddeliveryorder = new DeliveryOrderRequest { Data = resp.Entity, Action = ClinicEnums.Action.APPROVE.ToString() }; new DeliveryOrderValidator(_unitOfWork).Validate(receiveddeliveryorder, out _response); DeliveryOrderModel _model = resp.Entity; foreach (var item in resp.Entity.deliveryOrderDetailModels) { var requestproductingudang = new ProductInGudangRequest { Data = new ProductInGudangModel { Account = (AccountModel)Session["UserLogon"], stock = Convert.ToInt32(item.qty_request) > 0 ? Convert.ToInt32(item.qty_request) : Convert.ToInt32(item.qty_request), GudangId = _model.GudangId, ProductId = item.ProductId } }; var requesthistoryproductingudang = new HistoryProductInGudangRequest { Data = new HistoryProductInGudangModel { Account = (AccountModel)Session["UserLogon"], value = Convert.ToInt32(item.qty_request) > 0 ? Convert.ToInt32(item.qty_request) : Convert.ToInt32(item.qty_request), GudangId = Convert.ToInt32(_model.GudangId), ProductId = item.ProductId } }; var saveproductingudang = new ProductInGudangHandler(_unitOfWork).CreateOrEdit(requestproductingudang); var savehistoryproductingudang = new HistoryProductInGudangHandler(_unitOfWork).CreateOrEdit(requesthistoryproductingudang); } return(RedirectToAction("DeliveryOrderList")); }
public void Validate(DeliveryOrderRequest request, out DeliveryOrderResponse response) { response = new DeliveryOrderResponse(); if ((request.Action != null && request.Action.Equals(ClinicEnums.Action.DELETE.ToString())) || (request.Action != null && request.Action.Equals(ClinicEnums.Action.APPROVE.ToString()))) { if (request.Action != null && request.Action.Equals(ClinicEnums.Action.DELETE.ToString())) { ValidateForDelete(request, out response); } else { ValidateForApprove(request, out response); } } else { bool isHavePrivilege = true; if (request.Data.donumber == null || String.IsNullOrWhiteSpace(request.Data.donumber)) { errorFields.Add("Gudang Name"); } if (errorFields.Any()) { response.Status = false; response.Message = string.Format(Messages.ValidationErrorFields, String.Join(",", errorFields)); } if (request.Data.Id == 0) { isHavePrivilege = IsHaveAuthorization(ADD_M_DELIVERYORDER, request.Data.Account.Privileges.PrivilegeIDs); } else { isHavePrivilege = IsHaveAuthorization(EDIT_M_DELIVERYORDER, request.Data.Account.Privileges.PrivilegeIDs); } if (!isHavePrivilege) { response.Status = false; response.Message = Messages.UnauthorizedAccess; } if (response.Status) { response = new DeliveryOrderHandler(_unitOfWork).CreateOrEdit(request); } } }
public JsonResult ApproveDeliveryOrder(int id) { DeliveryOrderResponse _response = new DeliveryOrderResponse(); var request = new DeliveryOrderRequest { Data = new DeliveryOrderModel { Id = id, Account = Session["UserLogon"] == null ? new AccountModel() : (AccountModel)Session["UserLogon"] }, Action = ClinicEnums.Action.APPROVE.ToString() }; new DeliveryOrderValidator(_unitOfWork).Validate(request, out _response); return(Json(new { Status = _response.Status, Message = _response.Message }, JsonRequestBehavior.AllowGet)); }
private void ValidateForApprove(DeliveryOrderRequest request, out DeliveryOrderResponse response) { response = new DeliveryOrderResponse(); if (request.Action == ClinicEnums.Action.APPROVE.ToString()) { bool isHavePrivilege = IsHaveAuthorization(RECIVED_M_DELIVERYORDER, request.Data.Account.Privileges.PrivilegeIDs); if (!isHavePrivilege) { response.Status = false; response.Message = Messages.UnauthorizedAccess; } } if (response.Status) { response = new DeliveryOrderHandler(_unitOfWork).ApproveData(request); } }
public JsonResult CreateOrEditDeliveryOrder(DeliveryOrderModel _deliveryorder, List <DeliveryOrderDetailModel> deliveryOrderDetailModels) { if (Session["UserLogon"] != null) { _deliveryorder.Account = (AccountModel)Session["UserLogon"]; } _deliveryorder.Id = Convert.ToInt32(_deliveryorder.Id) > 0 ? _deliveryorder.Id : 0; var request = new DeliveryOrderRequest { Data = _deliveryorder }; DeliveryOrderResponse _response = new DeliveryOrderResponse(); new DeliveryOrderValidator(_unitOfWork).Validate(request, out _response); DeliveryOrderDetailResponse _deliveryorderdetailresponse = new DeliveryOrderDetailResponse(); if (deliveryOrderDetailModels != null) { foreach (var item in deliveryOrderDetailModels) { var deliveryorderdetailrequest = new DeliveryOrderDetailRequest { Data = item }; deliveryorderdetailrequest.Data.Account = (AccountModel)Session["UserLogon"]; // var requestnamabarang = new ProductRequest { Data = new ProductModel { Id = item.ProductId } }; ProductResponse namabarang = new ProductHandler(_unitOfWork).GetDetail(requestnamabarang); deliveryorderdetailrequest.Data.namabarang = namabarang.Entity.Name; new DeliveryOrderDetailValidator(_unitOfWork).Validate(deliveryorderdetailrequest, out _deliveryorderdetailresponse); } } return(Json(new { data = _deliveryorderdetailresponse.Data }, JsonRequestBehavior.AllowGet)); }
public ActionResult PrintDeliveryOrder(int id) { DeliveryOrderResponse _response = new DeliveryOrderResponse(); var request = new DeliveryOrderRequest { Data = new DeliveryOrderModel { Id = id } }; DeliveryOrderResponse resp = new DeliveryOrderHandler(_unitOfWork).GetDetail(request); DeliveryOrderModel _model = resp.Entity; ViewBag.Response = _response; return(new PartialViewAsPdf(_model) { PageOrientation = Orientation.Portrait, PageSize = Size.Folio, FileName = "DeliveryOrder" + _model.donumber + ".pdf" }); }
/// <summary> /// 微盟-订单发货(单个)(ec/order/deliveryOrder) /// </summary> public void DeliveryOrderToWm(DateTime startDate, DateTime endDate) { string preMsg = "微盟 订单发货(单个) "; string sql = @"select a.F_BillID, F_ExpressNum, F_ExpressCode from T_OrderLogisticsInformation a "; DataTable dtOrder = sd.GetDataTable(sql); Log.WriteLog(preMsg + "取得的记录数:" + dtOrder.Rows.Count + "行。", 1); if (dtOrder.Rows.Count == 0) { return; } foreach (DataRow drDetail in dtOrder.Rows) { DeliveryOrderRequest request = new DeliveryOrderRequest(); request.orderNo = NumUtil.ToLong(drDetail["F_BillID"]); request.deliveryNo = drDetail["F_ExpressNum"].ToString(); request.deliveryCompanyCode = drDetail["F_ExpressCode"].ToString(); DeliveryOrderResponse response = HttpPostToWm <DeliveryOrderResponse>("ec/order/deliveryOrder", request, preMsg); } }
public async Task <IActionResult> Index() { try { #region Qurey Booking Data from MySql then add to object TimeSpan fromTime = new TimeSpan(7, 0, 0); TimeSpan toTime = new TimeSpan(20, 0, 0); var from = (DateTime.Now.Date).Add(fromTime); var to = DateTime.Now.Date.Add(toTime); var strSql = $"select '' as No,'' as QRCode,substring(item.barcode, 2, 12) as Reference1,'' as Reference2,'' as Reference3,'' as Reference4,if (parcels.cod_amount > 0 ,'True','False')as IsPOSTPAY,if (parcels.cod_amount > 0 ,parcels.cod_amount,0)as POSTPAYAmount,parcels.recipient_name as ReceiveName,parcels.recipient_tel as Mobile,'' as Mobile2,parcels.recipient_address as Address,'' as Subdistrict,if (parcels.recipient_district <> '',parcels.recipient_district,postalCode.district)as District,postalCode.province as Province,parcels.recipient_zipcode as PostalCode,parcels.user_note as Remark,'' as ExchangeType,'' as ExchangeRemark,'' as Email,'' as Email2,1 as ItemNo,'' as SupplierSKU,'' as VendorSKU,'' as MerchantSKU,'' as ProductEANUPC,'Products 1' as ProductName,'' as ProductSize,'' as ProductColor,1 as ProductQuantity,'' as FulfillmentRemark,org.name as MerchantName,postalCode.province as MerchantAddress,org.name as MerchantContactPerson,org.phone as MerchantMobile ,orgGeo.json_info as GeographicLocation from tbl_manifest_items item left join tbl_manifest_sheets sheet on sheet.id = item.sheet_id left join tbl_scg_parcels parcels on parcels.tracking_number = item.barcode left join tbl_scg_postalCode postalCode on postalCode.postal_code = parcels.recipient_zipcode left join tbl_organization org on org.customer_code = parcels.sender_code left join tbl_auth_users user on user.id = item.user_created left join tbl_organization orgGeo on orgGeo.organization_id = user.organization_id where sheet.branch_destination = 'Alpha Fast' and item.status_deleted = 'N' and item.date_created between '2020-03-31' and '2020-03-31 20:00:00' and org.name is not null group by item.barcode"; var data = await appQuery.AlphaBookingViewModelsAsync <AlphaBookingViewModel>(strSql); var merchantName = from x in data.ToList() group x by x.MerchantName into g orderby g.Key select new { MerchantName = g.FirstOrDefault().MerchantName, MerchantAddress = g.FirstOrDefault().MerchantAddress, MerchantContactPerson = g.FirstOrDefault().MerchantContactPerson, IsNewReturn = false, Province = g.FirstOrDefault().Province, District = g.FirstOrDefault().District, Subdistrict = g.FirstOrDefault().Subdistrict, Latitude = g.FirstOrDefault().GeographicLocation.Split('"').ToArray(), Longitude = g.FirstOrDefault().GeographicLocation.Split('"').ToArray(), }; List <MerchantData> merchantDatas = new List <MerchantData>(); var i = 0; Random random = new Random(); foreach (var m in merchantName) { List <BookingData> bookingDatas = new List <BookingData>(); var bookings = data.Where(x => x.MerchantName == m.MerchantName); foreach (var b in bookings) { var ran = random.Next(111111111, 999999999); var mobile = CorrectMobile(b.Mobile); BookingData bookingData = new BookingData() { QRCode = $"SCG{ran}", Reference1 = b.Reference1, CustomerRemark = null, IsPOSTPAY = b.IsPOSTPAY == "True" ? true : false, Amount = b.POSTPAYAmount, Firstname = b.ReceiveName.Length <= 50 ? b.ReceiveName : b.ReceiveName.Substring(0, 50), Lastname = b.ReceiveName.Length <= 50 ? b.ReceiveName : b.ReceiveName.Substring(0, 50), Mobile = util.CorrectMobileFormat(b.Mobile), Address = b.Address, Province = b.Province, district = b.District, Subdistrict = b.Subdistrict, PostalCode = b.PostalCode, IsExchange = false, IsIVR = false, IsInsurance = false, IsSameDay = false }; bookingDatas.Add(bookingData); } MerchantData merchantData = new MerchantData() { MerchantName = m.MerchantName, MerchantAddress = m.MerchantAddress, MerchantContactPerson = m.MerchantContactPerson, IsNewReturn = false, Province = m.Province, District = m.District, Subdistrict = m.Subdistrict, Latitude = 13.736831, //Convert.ToDouble(m.Latitude[3]), Longitude = 100.606181, //Convert.ToDouble(m.Longitude[7]), BookingData = bookingDatas }; merchantDatas.Add(merchantData); DeliveryOrderRequest deliveryOrder = new DeliveryOrderRequest() { MerchantData = merchantDatas, AppointmentDateId = 2, AppointmentTimeId = 18 }; i++; //if (i >= 1) { // break; //} } DeliveryOrderRequest orderRequests = new DeliveryOrderRequest() { MerchantData = merchantDatas, AppointmentDateId = 0, AppointmentTimeId = 0 }; #endregion #region Call Alpha api usign Restsharp var c = new RestClient("https://apialpha.alphauat.com"); var r = new RestRequest("api/DeliveryOrder/MarketPlaceDeliveryOrderEntry", Method.POST); r.AddHeader("Authorization", "Alpha vxkx619iHkU5JXLWdXVE5WQX731C18D45crxFoe9N4NI1ltTl98QpztHGB/Q8l9JLFB+vdH/zFbA3T+9LNVWZMx94swrLieqn0tLjVq6lpYn6IOT3jgNmaGfWx5sbU12Qlx+LxSrK11TUcjhDYRN2KAxjGlrhMFIk73rp3cOBv74acFjFvZQnYWZ/QUxFkThZY2UfQettfR9zbaVF4MkBH0rG+WyOFhz10a42peh65G3z0ShrKJ+MvvBMcZLf+t8jYJ/neNIC0YCQevkfaDJY5IofeIfpsLzgMrYzD2NObCcMpK1ZfUZE/Qrp/NNTPCm4hFFQfMkg/DPEO2qp52HVhBCOVvC3pxs"); var serealize = JsonSerializer.Serialize <DeliveryOrderRequest>(orderRequests); r.AddJsonBody(orderRequests); var res = c.Execute(r); var model = JsonSerializer.Deserialize <CreateBookingModel>(res.Content); #endregion return(View()); } catch (Exception ex) { string messages = ex.InnerException != null ? ex.InnerException.Message : ex.Message; throw; } }