public async Task <IActionResult> Post([FromBody] ExpeditionViewModel ViewModel) { try { identityService.Username = User.Claims.Single(p => p.Type.Equals("username")).Value; IValidateService validateService = (IValidateService)serviceProvider.GetService(typeof(IValidateService)); validateService.Validate(ViewModel); var model = mapper.Map <Expedition>(ViewModel); await facade.Create(model, identityService.Username); Dictionary <string, object> Result = new ResultFormatter(ApiVersion, General.CREATED_STATUS_CODE, General.OK_MESSAGE) .Ok(); return(Created(String.Concat(Request.Path, "/", 0), Result)); } catch (ServiceValidationExeption e) { Dictionary <string, object> Result = new ResultFormatter(ApiVersion, General.BAD_REQUEST_STATUS_CODE, General.BAD_REQUEST_MESSAGE) .Fail(e); return(BadRequest(Result)); } catch (Exception e) { Dictionary <string, object> Result = new ResultFormatter(ApiVersion, General.INTERNAL_ERROR_STATUS_CODE, e.Message) .Fail(); return(StatusCode(General.INTERNAL_ERROR_STATUS_CODE, Result)); } }
public IActionResult GetExpeditionPDF(int id) { try { var indexAcceptPdf = Request.Headers["Accept"].ToList().IndexOf("application/pdf"); Expedition model = facade.ReadById(id); ExpeditionViewModel viewModel = mapper.Map <ExpeditionViewModel>(model); if (viewModel == null) { throw new Exception("Invalid Id"); } if (indexAcceptPdf < 0) { return(Ok(new { apiVersion = ApiVersion, statusCode = General.OK_STATUS_CODE, message = General.OK_MESSAGE, data = viewModel, })); } else { int clientTimeZoneOffset = int.Parse(Request.Headers["x-timezone-offset"].First()); //foreach (var item in viewModel.items) //{ // var garmentInvoice = invoiceFacade.ReadById((int)item.garmentInvoice.Id); // var garmentInvoiceViewModel = mapper.Map<GarmentInvoiceViewModel>(garmentInvoice); // item.garmentInvoice = garmentInvoiceViewModel; // foreach (var detail in item.details) // { // var deliveryOrder = deliveryOrderFacade.ReadById((int)detail.deliveryOrder.Id); // var deliveryOrderViewModel = mapper.Map<GarmentDeliveryOrderViewModel>(deliveryOrder); // detail.deliveryOrder = deliveryOrderViewModel; // } //} ExpeditionPdfTemplate PdfTemplateLocal = new ExpeditionPdfTemplate(); MemoryStream stream = PdfTemplateLocal.GeneratePdfTemplate(viewModel, serviceProvider, clientTimeZoneOffset); return(new FileStreamResult(stream, "application/pdf") { FileDownloadName = $"{viewModel.code}.pdf" }); } } catch (Exception e) { Dictionary <string, object> Result = new ResultFormatter(ApiVersion, General.INTERNAL_ERROR_STATUS_CODE, e.Message) .Fail(); return(StatusCode(General.INTERNAL_ERROR_STATUS_CODE, Result)); } }
public Expedition MapToModel(ExpeditionViewModel expeditionVM) { Expedition expedition = new Expedition(); expedition.Id = expeditionVM._id; expedition.UId = expeditionVM.UId; expedition._IsDeleted = expeditionVM._deleted; expedition.Active = expeditionVM._active; expedition._CreatedUtc = expeditionVM._createdDate; expedition._CreatedBy = expeditionVM._createdBy; expedition._CreatedAgent = expeditionVM._createAgent; expedition._LastModifiedUtc = expeditionVM._updatedDate; expedition._LastModifiedBy = expeditionVM._updatedBy; expedition._LastModifiedAgent = expeditionVM._updateAgent; expedition.Code = expeditionVM.code; expedition.Description = expeditionVM.description; expedition.Name = expedition.Name; return(expedition); }
public MemoryStream GeneratePdfTemplate(ExpeditionViewModel viewModel, IServiceProvider serviceProvider, int clientTimeZoneOffset /*, IGarmentDeliveryOrderFacade DOfacad*/) { Font header_font = FontFactory.GetFont(BaseFont.HELVETICA, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 18); Font normal_font = FontFactory.GetFont(BaseFont.HELVETICA, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 9); Font normal_font1 = FontFactory.GetFont(BaseFont.HELVETICA, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 8); Font bold_font = FontFactory.GetFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 20); Font bold_font1 = FontFactory.GetFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 8); Document document = new Document(PageSize.A4, 40, 40, 40, 40); document.AddHeader("Header", viewModel.code); MemoryStream stream = new MemoryStream(); PdfWriter writer = PdfWriter.GetInstance(document, stream); writer.PageEvent = new PDFPages(); document.Open(); PdfPCell cellLeftNoBorder = new PdfPCell() { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_LEFT }; PdfPCell cellRightNoBorder = new PdfPCell() { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_RIGHT }; Chunk chkHeader = new Chunk(" "); Phrase pheader = new Phrase(chkHeader); HeaderFooter header = new HeaderFooter(pheader, false); header.Border = Rectangle.NO_BORDER; header.Alignment = Element.ALIGN_RIGHT; document.Header = header; #region Header string titleString = "BON PENGELUARAN BARANG\n\n"; Paragraph title = new Paragraph(titleString, bold_font) { Alignment = Element.ALIGN_CENTER }; document.Add(title); bold_font.SetStyle(Font.NORMAL); //string addressString = "PT DAN LIRIS" + "\n" + "JL. Merapi No.23" + "\n" + "Banaran, Grogol, Kab. Sukoharjo" + "\n" + "Jawa Tengah 57552 - INDONESIA" + "\n" + "PO.BOX 166 Solo 57100" + "\n" + "Telp. (0271) 740888, 714400" + "\n" + "Fax. (0271) 735222, 740777"; //Paragraph address = new Paragraph(addressString, bold_font) { Alignment = Element.ALIGN_LEFT }; //document.Add(address); //bold_font.SetStyle(Font.NORMAL); PdfPTable tableInternNoteHeader = new PdfPTable(2); tableInternNoteHeader.SetWidths(new float[] { 7.5f, 4.5f }); PdfPCell cellInternNoteHeaderLeft = new PdfPCell() { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_LEFT }; PdfPCell cellInternNoteHeaderRight = new PdfPCell() { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_LEFT }; cellInternNoteHeaderLeft.Phrase = new Phrase("PT. MAJOR MINOR KREASI NUSANTARA", bold_font1); tableInternNoteHeader.AddCell(cellInternNoteHeaderLeft); cellInternNoteHeaderLeft.Phrase = new Phrase("No. Bon" + " : " + viewModel.code, normal_font); tableInternNoteHeader.AddCell(cellInternNoteHeaderLeft); cellInternNoteHeaderRight.Phrase = new Phrase("Equity Tower 15th Floor Suite C, SCBD Lot 9, Jl. Jenderal Sudirman Kav 52-53 Jakarta 12190, Indonesia", normal_font); tableInternNoteHeader.AddCell(cellInternNoteHeaderRight); //cellInternNoteHeaderLeft.Phrase = new Phrase("Password" + " : " + viewModel.password, normal_font); //tableInternNoteHeader.AddCell(cellInternNoteHeaderLeft); //cellInternNoteHeaderRight.Phrase = new Phrase("", normal_font); //tableInternNoteHeader.AddCell(cellInternNoteHeaderRight); cellInternNoteHeaderLeft.Phrase = new Phrase("Tanggal" + " : " + viewModel.CreatedUtc.ToString("dd MMMM yyyy", new CultureInfo("id-ID")) + "\n\n\n", normal_font); tableInternNoteHeader.AddCell(cellInternNoteHeaderLeft); //cellInternNoteHeaderRight.Phrase = new Phrase("Dari" + " : " + viewModel.source.name, normal_font); //tableInternNoteHeader.AddCell(cellInternNoteHeaderRight); //cellInternNoteHeaderLeft.Phrase = new Phrase("", normal_font); //tableInternNoteHeader.AddCell(cellInternNoteHeaderLeft); string destination = ""; foreach (var i in viewModel.items) { destination = i.spkDocsViewModel.destination.name; } cellInternNoteHeaderRight.Phrase = new Phrase("Tujuan" + " : " + destination, normal_font); tableInternNoteHeader.AddCell(cellInternNoteHeaderRight); cellInternNoteHeaderLeft.Phrase = new Phrase("", normal_font); tableInternNoteHeader.AddCell(cellInternNoteHeaderLeft); cellInternNoteHeaderRight.Phrase = new Phrase("Ekspedisi" + " : " + viewModel.expeditionService.name, normal_font); tableInternNoteHeader.AddCell(cellInternNoteHeaderRight); cellInternNoteHeaderLeft.Phrase = new Phrase("", normal_font); tableInternNoteHeader.AddCell(cellInternNoteHeaderLeft); cellInternNoteHeaderRight.Phrase = new Phrase("Total Berat (Kg)" + " : " + viewModel.weight, normal_font); tableInternNoteHeader.AddCell(cellInternNoteHeaderRight); cellInternNoteHeaderLeft.Phrase = new Phrase("", normal_font); tableInternNoteHeader.AddCell(cellInternNoteHeaderLeft); //cellInternNoteHeaderRight.Phrase = new Phrase("Keterangan" + " : " + "" + "\n\n", normal_font); //tableInternNoteHeader.AddCell(cellInternNoteHeaderRight); PdfPCell cellInternNoteHeader = new PdfPCell(tableInternNoteHeader); // dont remove tableInternNoteHeader.ExtendLastRow = false; tableInternNoteHeader.SpacingAfter = 10f; document.Add(tableInternNoteHeader); #endregion #region Table_Of_Content PdfPCell cellCenter = new PdfPCell() { Border = Rectangle.TOP_BORDER | Rectangle.LEFT_BORDER | Rectangle.BOTTOM_BORDER | Rectangle.RIGHT_BORDER, HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE, Padding = 5 }; PdfPCell cellRight = new PdfPCell() { Border = Rectangle.TOP_BORDER | Rectangle.LEFT_BORDER | Rectangle.BOTTOM_BORDER | Rectangle.RIGHT_BORDER, HorizontalAlignment = Element.ALIGN_RIGHT, VerticalAlignment = Element.ALIGN_MIDDLE, Padding = 5 }; PdfPCell cellLeft = new PdfPCell() { Border = Rectangle.TOP_BORDER | Rectangle.LEFT_BORDER | Rectangle.BOTTOM_BORDER | Rectangle.RIGHT_BORDER, HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE, Padding = 5 }; PdfPTable tableContent = new PdfPTable(5); tableContent.SetWidths(new float[] { 2f, 4f, 5f, 6.5f, 5.5f }); cellCenter.Phrase = new Phrase("No", bold_font1); tableContent.AddCell(cellCenter); cellCenter.Phrase = new Phrase("Packing List", bold_font1); tableContent.AddCell(cellCenter); cellCenter.Phrase = new Phrase("Password", bold_font1); tableContent.AddCell(cellCenter); cellCenter.Phrase = new Phrase("Berat (Kg)", bold_font1); tableContent.AddCell(cellCenter); cellCenter.Phrase = new Phrase("Total Barang", bold_font1); tableContent.AddCell(cellCenter); //double totalPriceTotal = 0; double total = 0; List <TableContent> TableContents = new List <TableContent>(); int index = 1; foreach (ExpeditionItemViewModel item in viewModel.items) { foreach (ExpeditionDetailViewModel detail in item.details) { total += detail.sendQuantity; } TableContents.Add(new TableContent { No = index++, PackingList = item.spkDocsViewModel.packingList, Password = item.spkDocsViewModel.password, Weight = item.weight, Total = total.ToString() }); //totalPriceTotal += item.quantity * item.item.domesticSale; //total += item.quantity; } foreach (TableContent c in TableContents.OrderBy(o => o.No)) { cellCenter.Phrase = new Phrase(c.No.ToString(), normal_font1); tableContent.AddCell(cellCenter); cellCenter.Phrase = new Phrase(c.PackingList, normal_font1); tableContent.AddCell(cellCenter); cellCenter.Phrase = new Phrase(c.Password, normal_font1); tableContent.AddCell(cellCenter); cellCenter.Phrase = new Phrase(c.Weight.ToString(), normal_font1); tableContent.AddCell(cellCenter); cellCenter.Phrase = new Phrase(c.Total, normal_font1); tableContent.AddCell(cellCenter); } PdfPCell cellContent = new PdfPCell(tableContent); // dont remove tableContent.ExtendLastRow = false; tableContent.SpacingAfter = 20f; document.Add(tableContent); #endregion #region Total PdfPTable tabletotal = new PdfPTable(2); tabletotal.SetWidths(new float[] { 17.5f, 5.5f }); PdfPCell cellTotalContent = new PdfPCell() { Border = Rectangle.TOP_BORDER | Rectangle.LEFT_BORDER | Rectangle.BOTTOM_BORDER | Rectangle.RIGHT_BORDER, HorizontalAlignment = Element.ALIGN_CENTER }; cellTotalContent.Phrase = new Phrase("Total", normal_font1); tabletotal.AddCell(cellTotalContent); //cellTotalContent.Phrase = new Phrase("" + total, normal_font1); //tabletotal.AddCell(cellTotalContent); cellTotalContent.Phrase = new Phrase("" + String.Format("{0:n}", total), normal_font1); tabletotal.AddCell(cellTotalContent); PdfPCell cellTotal = new PdfPCell(tabletotal); // dont remove tabletotal.ExtendLastRow = false; tabletotal.SpacingBefore = 20f; tabletotal.SpacingAfter = 20f; document.Add(tabletotal); #endregion //PdfPTable tableContent2 = new PdfPTable(3); //tableContent2.SetWidths(new float[] { 13f, 4.5f, 5.5f }); //List<TableContent2> tableContents2 = new List<TableContent2>(); //tableContents2.Add(new TableContent2 //{ // Total = "Total", // QtyTotal = total.ToString(), // PriceTotal = String.Format("{0:n}", totalPriceTotal.ToString()) //}); //foreach (TableContent2 c in tableContents2) //{ // cellLeft.Phrase = new Phrase(c.Total, normal_font1); // tableContent.AddCell(cellLeft); // cellLeft.Phrase = new Phrase(c.QtyTotal, normal_font1); // tableContent.AddCell(cellLeft); // cellLeft.Phrase = new Phrase(c.PriceTotal, normal_font1); // tableContent.AddCell(cellLeft); //} //PdfPCell cellContent2 = new PdfPCell(tableContent2); // dont remove //tableContent.ExtendLastRow = false; //tableContent.SpacingAfter = 20f; //document.Add(tableContent); //#region Footer //PdfPTable tableFooter = new PdfPTable(2); //tableFooter.SetWidths(new float[] { 1f, 1f }); //PdfPTable tableFooterLeft = new PdfPTable(2); //tableFooterLeft.SetWidths(new float[] { 3f, 5f }); //PdfPCell cellInternNoteFooterLeft = new PdfPCell() { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_LEFT }; //PdfPCell cellInternNoteFooterRight = new PdfPCell() { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_LEFT }; ////foreach (var unit in units) ////{ //// if (unit.Value == 0) //// { //// cellLeftNoBorder.Phrase = new Phrase($"Total {unit.Key}", normal_font); //// tableFooterLeft.AddCell(cellLeftNoBorder); //// cellLeftNoBorder.Phrase = new Phrase($": -", normal_font); //// tableFooterLeft.AddCell(cellLeftNoBorder); //// } //// else //// { //// cellLeftNoBorder.Phrase = new Phrase($"Total {unit.Key}", normal_font); //// tableFooterLeft.AddCell(cellLeftNoBorder); //// cellLeftNoBorder.Phrase = new Phrase($": {unit.Value.ToString("n", new CultureInfo("id-ID"))}", normal_font); //// tableFooterLeft.AddCell(cellLeftNoBorder); //// } ////} //PdfPTable tableFooterRight = new PdfPTable(2); //tableFooterRight.SetWidths(new float[] { 5f, 5f }); ////cellLeftNoBorder.Phrase = new Phrase($"Total Harga Pokok (DPP)", normal_font); ////tableFooterRight.AddCell(cellLeftNoBorder); ////cellLeftNoBorder.Phrase = new Phrase($": " + totalPriceTotal.ToString("N", new CultureInfo("id-ID")), normal_font); ////tableFooterRight.AddCell(cellLeftNoBorder); ////cellLeftNoBorder.Phrase = new Phrase("Mata Uang", normal_font); ////tableFooterRight.AddCell(cellLeftNoBorder); ////cellLeftNoBorder.Phrase = new Phrase($": " + viewModel.currency.Code, normal_font); ////tableFooterRight.AddCell(cellLeftNoBorder); ////cellLeftNoBorder.Phrase = new Phrase("Total Harga Pokok (Rp)", normal_font); ////tableFooterRight.AddCell(cellLeftNoBorder); ////cellLeftNoBorder.Phrase = new Phrase($": " + total.ToString("N", new CultureInfo("id-ID")), normal_font); ////tableFooterRight.AddCell(cellLeftNoBorder); ////cellLeftNoBorder.Phrase = new Phrase("Total Nota Koreksi", normal_font); ////tableFooterRight.AddCell(cellLeftNoBorder); ////if (correctionNote != null) ////{ //// cellLeftNoBorder.Phrase = new Phrase($": " + totalcorrection.ToString("N", new CultureInfo("id-ID")), normal_font); //// tableFooterRight.AddCell(cellLeftNoBorder); ////} ////else ////{ //// cellLeftNoBorder.Phrase = new Phrase($": " + 0, normal_font); //// tableFooterRight.AddCell(cellLeftNoBorder); ////} ////cellLeftNoBorder.Phrase = new Phrase("Total Nota PPn", normal_font); ////tableFooterRight.AddCell(cellLeftNoBorder); ////cellLeftNoBorder.Phrase = new Phrase($": " + ppn.ToString("N", new CultureInfo("id-ID")), normal_font); ////tableFooterRight.AddCell(cellLeftNoBorder); ////cellLeftNoBorder.Phrase = new Phrase("Total Nota PPh", normal_font); ////tableFooterRight.AddCell(cellLeftNoBorder); ////cellLeftNoBorder.Phrase = new Phrase($": " + pph.ToString("N", new CultureInfo("id-ID")), normal_font); ////tableFooterRight.AddCell(cellLeftNoBorder); ////cellLeftNoBorder.Phrase = new Phrase("Total yang Harus Dibayar", normal_font); ////tableFooterRight.AddCell(cellLeftNoBorder); ////cellLeftNoBorder.Phrase = new Phrase($": " + maxtotal.ToString("N", new CultureInfo("id-ID")), normal_font); ////tableFooterRight.AddCell(cellLeftNoBorder); //PdfPCell cellFooterLeft = new PdfPCell(tableFooterLeft) { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_CENTER }; //tableFooter.AddCell(cellFooterLeft); //PdfPCell cellFooterRight = new PdfPCell(tableFooterRight) { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_CENTER }; //tableFooter.AddCell(cellFooterRight); //PdfPCell cellFooter = new PdfPCell(tableFooter); // dont remove //tableFooter.ExtendLastRow = false; //tableFooter.SpacingAfter = 20f; //document.Add(tableFooter); //#endregion #region TableSignature PdfPTable tableSignature = new PdfPTable(3); PdfPCell cellSignatureContent = new PdfPCell() { Border = Rectangle.TOP_BORDER | Rectangle.LEFT_BORDER | Rectangle.BOTTOM_BORDER | Rectangle.RIGHT_BORDER, HorizontalAlignment = Element.ALIGN_CENTER }; cellSignatureContent.Phrase = new Phrase("Penerima/Pembeli\n\n\n\n\n\n\n(________________________________)", bold_font1); tableSignature.AddCell(cellSignatureContent); cellSignatureContent.Phrase = new Phrase("Bagian Pengiriman\n\n\n\n\n\n\n(________________________________)", bold_font1); tableSignature.AddCell(cellSignatureContent); cellSignatureContent.Phrase = new Phrase("Yang Membuat\n\n\n\n\n\n\n(________________________________)", bold_font1); tableSignature.AddCell(cellSignatureContent); PdfPCell cellSignature = new PdfPCell(tableSignature); // dont remove tableSignature.ExtendLastRow = false; tableSignature.SpacingBefore = 20f; tableSignature.SpacingAfter = 20f; document.Add(tableSignature); #endregion document.Close(); byte[] byteInfo = stream.ToArray(); stream.Write(byteInfo, 0, byteInfo.Length); stream.Position = 0; return(stream); }
public async Task Should_Success_Validate_DataAsync() { ExpeditionViewModel ViewModel = new ExpeditionViewModel { }; Assert.True(ViewModel.Validate(null).Count() > 0); ExpeditionViewModel expservice = new ExpeditionViewModel { expeditionService = new Lib.ViewModels.NewIntegrationViewModel.ExpeditionServiceViewModel { code = "code", name = "name", _id = 1 }, }; Assert.True(expservice.Validate(null).Count() > 0); ExpeditionViewModel itemViewModel = new ExpeditionViewModel { expeditionService = new Lib.ViewModels.NewIntegrationViewModel.ExpeditionServiceViewModel { code = "code", name = "name", _id = 1 }, items = new List <ExpeditionItemViewModel> { new ExpeditionItemViewModel { spkDocsViewModel = new Lib.ViewModels.SpkDocsViewModel.SPKDocsViewModel { code = "test", Weight = 0 } } } }; Assert.True(itemViewModel.Validate(null).Count() > 0); ExpeditionViewModel detailViewModel = new ExpeditionViewModel { expeditionService = new Lib.ViewModels.NewIntegrationViewModel.ExpeditionServiceViewModel { code = "code", name = "name", _id = 1 }, items = new List <ExpeditionItemViewModel> { new ExpeditionItemViewModel { spkDocsViewModel = new Lib.ViewModels.SpkDocsViewModel.SPKDocsViewModel { code = "test", Weight = 5, }, details = new List <ExpeditionDetailViewModel> { new ExpeditionDetailViewModel { sendQuantity = 0, } } } } }; Assert.True(detailViewModel.Validate(null).Count() > 0); DbSet <Inventory> dbSetInventory = _dbContext(GetCurrentMethod()).Set <Inventory>(); InventoryFacade facade = new InventoryFacade(GetServiceProvider().Object, _dbContext(GetCurrentMethod())); var model = await invendataUtil(facade, GetCurrentMethod(), _dbContext(GetCurrentMethod())).GetTestData(); ExpeditionViewModel detailViewModel2 = new ExpeditionViewModel { expeditionService = new Lib.ViewModels.NewIntegrationViewModel.ExpeditionServiceViewModel { code = "code", name = "name", _id = 1 }, items = new List <ExpeditionItemViewModel> { new ExpeditionItemViewModel { spkDocsViewModel = new Lib.ViewModels.SpkDocsViewModel.SPKDocsViewModel { code = "test", Weight = 5, source = new Lib.ViewModels.NewIntegrationViewModel.SourceViewModel { code = model.StorageCode, name = model.StorageName, _id = model.StorageId } }, details = new List <ExpeditionDetailViewModel> { new ExpeditionDetailViewModel { sendQuantity = 2, item = new Lib.ViewModels.NewIntegrationViewModel.ItemViewModel { articleRealizationOrder = model.ItemArticleRealizationOrder, code = model.ItemCode, name = model.ItemName, } } } } } }; Assert.True(detailViewModel2.Validate(null).Count() > 0); ExpeditionViewModel detailViewModel3 = new ExpeditionViewModel { expeditionService = new Lib.ViewModels.NewIntegrationViewModel.ExpeditionServiceViewModel { code = "code", name = "name", _id = 1 }, items = new List <ExpeditionItemViewModel> { new ExpeditionItemViewModel { spkDocsViewModel = new Lib.ViewModels.SpkDocsViewModel.SPKDocsViewModel { code = "test", Weight = 5, source = new Lib.ViewModels.NewIntegrationViewModel.SourceViewModel { code = model.StorageCode, name = model.StorageName, _id = model.StorageId } }, details = new List <ExpeditionDetailViewModel> { new ExpeditionDetailViewModel { sendQuantity = model.Quantity, item = new Lib.ViewModels.NewIntegrationViewModel.ItemViewModel { articleRealizationOrder = model.ItemArticleRealizationOrder, code = model.ItemCode, name = model.ItemName, }, quantity = model.Quantity + 1 } } } } }; Assert.True(detailViewModel3.Validate(null).Count() > 0); ExpeditionViewModel detailViewModel4 = new ExpeditionViewModel { expeditionService = new Lib.ViewModels.NewIntegrationViewModel.ExpeditionServiceViewModel { code = "code", name = "name", _id = 1 }, items = new List <ExpeditionItemViewModel> { new ExpeditionItemViewModel { spkDocsViewModel = new Lib.ViewModels.SpkDocsViewModel.SPKDocsViewModel { code = "test", Weight = 5, source = new Lib.ViewModels.NewIntegrationViewModel.SourceViewModel { code = model.StorageCode, name = model.StorageName, _id = model.StorageId } }, details = new List <ExpeditionDetailViewModel> { new ExpeditionDetailViewModel { sendQuantity = model.Quantity, item = new Lib.ViewModels.NewIntegrationViewModel.ItemViewModel { articleRealizationOrder = model.ItemArticleRealizationOrder, code = model.ItemCode, name = model.ItemName, }, quantity = model.Quantity, remark = "" } } } } }; Assert.True(detailViewModel4.Validate(null).Count() > 0); }
private static ExpeditionViewModel Early(ExpeditionViewModel vm1, ExpeditionViewModel vm2) { // 2 つの遠征を比較して早く帰ってくるほうを返すやつ if (vm1.Source.IsInExecution) { if (vm2.Source.IsInExecution) { return vm1.Source.ReturnTime < vm2.Source.ReturnTime ? vm1 : vm2; } return vm1; } return vm2; }