public bool UpdateConsignment(ConsignmentModel model) { try { var data = tRSEntities4.ConsignmentOperations.Where(x => x.id == model.id && x.isActive == true).FirstOrDefault(); if (data != null) { data.cnNo = model.cnNo; data.cndate = model.cndate; data.expectedDelivery = model.expectedDelivery; data.from = model.from; data.to = model.to; data.godownNo = model.godownNo; data.paymentType = model.paymentType; data.actualWeight = model.actualWeight; data.consignee = model.consignee; data.deliveryBranch = model.deliveryBranch; data.virtualGoddownNo = model.virtualGoddownNo; data.consignorDetails = model.consignorDetails; data.consignor = model.consignor; data.agentName = model.agentName; data.agentDetails = model.agentDetails; data.bookingType = model.bookingType; data.deliveryType = model.deliveryType; data.modeOfTransport = model.modeOfTransport; data.invoiceNo = model.invoiceNo; data.invoiceValue = model.invoiceValue; data.consignorInvoice = model.consignorInvoice; data.freightBasis = model.freightBasis; data.ftl = model.ftl; data.isCcAttached = model.isCcAttached; data.isCod = model.isCod; data.chargeWeight = model.chargeWeight; data.freightRate = model.freightRate; data.privateMark = model.privateMark; data.insuredBy = model.insuredBy; data.freight = model.freight; data.surcharge = model.surcharge; data.hamaliCharge = model.hamaliCharge; data.localCartages = model.localCartages; data.doorDeliveryCharge = model.doorDeliveryCharge; data.statisticalCharges = model.statisticalCharges; data.miscellaneousCharges = model.miscellaneousCharges; data.godownCharges = model.godownCharges; data.cod = model.cod; data.financeEffect = model.financeEffect; data.packingtype = model.packingtype; tRSEntities4.SaveChanges(); return(true); } else { return(false); } } catch (Exception e) { throw e; } }
public ActionResult Index(ConsignmentModel model) { ConsignmentService objService = new ConsignmentService(); int uid = 0; if (Session["UserId"] != null) { uid = Convert.ToInt32(Session["UserId"].ToString()); int cid = 0; if (Session["CompID"] != null) { cid = Convert.ToInt32(Session["CompID"].ToString()); } if (model.CompID == null) { model.CompID = cid; } model.InvoiceNo = "GR"; model.CreatedBy = uid; model.CreatedDate = System.DateTime.Now; model.Status = true; objService.Insert(model); } return(RedirectToAction("Index", new { @menuId = model.Viewbagidformenu })); }
public async Task <IActionResult> GetCarrier2Quote([FromBody] ConsignmentModel consignmentModel) { float amount = 0; if (consignmentModel != null && consignmentModel.Cartons != null) { if (ModelState.IsValid) { // Loop to calculate the amount on the basis of height, width and number of cartons requested foreach (var carton in consignmentModel.Cartons.Select((value, index) => new { index, value })) { amount += (carton.value.NoOfCartons * carton.value.Height * carton.value.Width); } //Creating json object that will retrun amount with property name as "amount" JObject jObject = new JObject(new JProperty("amount", amount)); /** Putting the thread on sleep for 2 sec to check if there is a deplay in response then API * will not wait and will cancel the request according to the cancel time*/ Thread.Sleep(2000); return(Ok(JsonConvert.SerializeObject(jObject))); } return(Conflict(ModelState)); } return(BadRequest("Please check the input data and try again")); }
public int Update(ConsignmentModel model) { Mapper.CreateMap <ConsignmentModel, ConsignmentMaster>(); ConsignmentMaster objComp = Dbcontext.ConsignmentMasters.SingleOrDefault(m => m.GrNo == model.GrNo); objComp = Mapper.Map(model, objComp); return(Dbcontext.SaveChanges()); }
public ConsignmentModel GetById(int id) { Mapper.CreateMap <ConsignmentMaster, ConsignmentModel>(); ConsignmentMaster objComp = Dbcontext.ConsignmentMasters.SingleOrDefault(m => m.GrNo == id); ConsignmentModel objCItem = Mapper.Map <ConsignmentModel>(objComp); return(objCItem); }
public int Insert(ConsignmentModel model) { Mapper.CreateMap <ConsignmentModel, ConsignmentMaster>(); ConsignmentMaster objCompany = Mapper.Map <ConsignmentMaster>(model); Dbcontext.ConsignmentMasters.Add(objCompany); return(Dbcontext.SaveChanges()); }
private void Test_GetCarrier2Quote_InValid() { //Arrange HomeController homeController = new HomeController(mock.Object); var payload = new ConsignmentModel(); // Act var result = homeController.GetCarrier2Quote(payload); // Assert Assert.IsType <BadRequestObjectResult>(result.Result); }
public ActionResult Edit(ConsignmentModel model) { ConsignmentService objService = new ConsignmentService(); int uid = 0; if (Session["UserId"] != null) { uid = Convert.ToInt32(Session["UserId"].ToString()); model.UpdatedBy = uid; model.UpdatedDate = System.DateTime.Now; objService.Update(model); } return(RedirectToAction("Index", new { @menuId = model.Viewbagidformenu })); }
public ActionResult Invoice(string id) { ConsignmentService objService = new ConsignmentService(); ConsignmentModel objModel = new ConsignmentModel(); EncDec objEnDec = new EncDec(); int cid = Convert.ToInt32(objEnDec.Decrypt(id)); objModel = objService.getGRbyID(cid); //List<ChallanModel> lstChallan = new List<ChallanModel>(); //lstChallan = objService.getChallanTran(id); //objModel.ListChallan = new List<ChallanModel>(); //objModel.ListChallan.AddRange(lstChallan); return(View(objModel)); }
private void Test_GetCarrier2Quote_InValidModelState() { //Arrange HomeController homeController = new HomeController(mock.Object); var payload = new ConsignmentModel(); payload.Cartons = new List <DimensionModel>(); homeController.ModelState.AddModelError("Address", "Address is required"); // Act var result = homeController.GetCarrier2Quote(payload); // Assert Assert.IsType <ConflictObjectResult>(result.Result); }
private async Task Test_GetCarrier2Quote_Valid() { //Arrange HomeController homeController = new HomeController(mock.Object); List <DimensionModel> cartons = new List <DimensionModel>(); cartons.Add(new DimensionModel() { Height = 30, Width = 30, NoOfCartons = 10 }); cartons.Add(new DimensionModel() { Height = 10, Width = 10, NoOfCartons = 20 }); AddressModel address = new AddressModel() { Address = "Test Address", City = "Test City", State = "Test State", ZipCode = "6a7f88", ContactNumber = "1111111" }; var payload = new ConsignmentModel() { Consignee = address, Consignor = address, Cartons = cartons }; // Act var okResult = (await homeController.GetCarrier2Quote(payload)) as OkObjectResult; var objectResult = (await homeController.GetCarrier2Quote(payload)) as ObjectResult; var jObjResult = JObject.Parse(objectResult.Value.ToString()); // Assert Assert.IsType <OkObjectResult>(okResult); Assert.Equal(11000, jObjResult["amount"]); }
public ActionResult getGRDetail(int GRID) { int uid = 0; int cid = 0; int rid = 0; if (Session["UserId"] != null) { uid = Convert.ToInt32(Session["UserId"].ToString()); cid = Convert.ToInt32(Session["CompID"].ToString()); rid = Convert.ToInt32(Session["CompID"].ToString()); } ConsignmentModel objModel = new ConsignmentModel(); ChallanService objService = new ChallanService(); objModel = objService.getGR(GRID); //return Json(objModel, JsonRequestBehavior.AllowGet); return(PartialView("_GRDetail", objModel)); }
// // GET: /Consignment/ public ActionResult Index() { ConsignmentService objService = new ConsignmentService(); ConsignmentModel objModel = new ConsignmentModel(); List <ConsignmentModel> objList = new List <ConsignmentModel>(); int uid = 0; int cid = 0; int rid = 0; if (Session["UserId"] != null) { uid = Convert.ToInt32(Session["UserId"].ToString()); cid = Convert.ToInt32(Session["CompID"].ToString()); rid = Convert.ToInt32(Session["CompID"].ToString()); } objList = objService.GetALL(rid, cid); objModel.ListConsignment = new List <ConsignmentModel>(); objModel.ListConsignment.AddRange(objList); List <PartyModel> lstConsigner = new List <PartyModel>(); lstConsigner = objService.getConsigner(rid, cid); objModel.ListConsigner = new List <PartyModel>(); objModel.ListConsigner.AddRange(lstConsigner); List <PartyModel> lstConsignee = new List <PartyModel>(); lstConsignee = objService.getConsigner(rid, cid); objModel.ListConsignee = new List <PartyModel>(); objModel.ListConsignee.AddRange(lstConsignee); List <VehicleItem> lstVehicle = new List <VehicleItem>(); lstVehicle = objService.getVehicle(rid, cid); objModel.ListVehicle = new List <VehicleItem>(); objModel.ListVehicle.AddRange(lstVehicle); ViewBag.Menuid = (Request.QueryString["menuid"]); return(View(objModel)); }
public BringRequestModel MapDirectBookingDetailToShipmentRequestDto(DirectBookingShipmentDraftDetail directBookingDetail) { BringRequestModel bringRequest = new BringRequestModel(); if (AppSettings.ApplicationMode == FrayteApplicationMode.Test) { bringRequest.testIndicator = true; } else { bringRequest.testIndicator = false; } bringRequest.schemaVersion = 1; bringRequest.consignments = new List <ConsignmentModel>(); var packages = new List <Models.Bring.Package>(); Models.Bring.Package package = new Models.Bring.Package(); for (int i = 0; i < directBookingDetail.Packages.Count; i++) { for (int j = 0; j < directBookingDetail.Packages[i].CartoonValue; j++) { package.weightInKg = directBookingDetail.Packages[i].Weight.ToString("0.##"); package.goodsDescription = directBookingDetail.Packages[i].Content; package.dimensions = new Dimensions() { heightInCm = directBookingDetail.Packages[i].Height, lengthInCm = directBookingDetail.Packages[i].Length, widthInCm = directBookingDetail.Packages[i].Width, }; package.containerId = directBookingDetail.FrayteNumber; package.packageType = ""; package.numberOfItems = ""; package.correlationId = "PACKAGE-" + directBookingDetail.FrayteNumber; packages.Add(package); } } var ShipFrom = new ExpressRepository().getHubAddress(directBookingDetail.ShipTo.Country.CountryId, directBookingDetail.ShipTo.PostCode, directBookingDetail.ShipTo.State); ConsignmentModel consign = new ConsignmentModel() { shippingDateTime = DateTime.Now.AddDays(1).ToString("yyyy-MM-ddTHH:mm:ss"), parties = new Parties() { sender = new Sender() { //name = string.IsNullOrWhiteSpace(ShipFrom.CompanyName) ? ShipFrom.FirstName + " " + ShipFrom.LastName : ShipFrom.CompanyName, //addressLine = ShipFrom.Address, //addressLine2 = ShipFrom.Address2, //additionalAddressInfo = "", //postalCode = ShipFrom.PostCode, //city = ShipFrom.City, //countryCode = ShipFrom.Country.Code2, //reference = directBookingDetail.FrayteNumber + "-" + directBookingDetail.ReferenceDetail.Reference1, //contact = new Contact //{ // name = string.IsNullOrEmpty(ShipFrom.FirstName + " " + ShipFrom.LastName) ? ShipFrom.CompanyName : ShipFrom.FirstName + " " + ShipFrom.LastName, // email = string.IsNullOrEmpty(ShipFrom.Email) ? "*****@*****.**" : ShipFrom.Email, // phoneNumber = ShipFrom.Phone //} name = "Priority Cargo AS", addressLine = "Skur 97,Kongshavnveien 29,", addressLine2 = "Kongshavnveien 29,", additionalAddressInfo = "", postalCode = "0193", city = "Oslo", countryCode = "NO", reference = directBookingDetail.FrayteNumber + "-" + directBookingDetail.ReferenceDetail.Reference1, contact = new Contact { name = "Priority Cargo AS", email = "*****@*****.**", phoneNumber = "+47 9760 0402" } }, recipient = new Recipient() { name = string.IsNullOrWhiteSpace(directBookingDetail.ShipTo.CompanyName) ? directBookingDetail.ShipTo.FirstName + " " + directBookingDetail.ShipTo.LastName : directBookingDetail.ShipTo.CompanyName, addressLine = directBookingDetail.ShipTo.Address, addressLine2 = directBookingDetail.ShipTo.Address2, additionalAddressInfo = "", postalCode = directBookingDetail.ShipTo.PostCode, city = directBookingDetail.ShipTo.City, countryCode = directBookingDetail.ShipTo.Country.Code2, //reference = directBookingDetail.FrayteNumber + "-" + directBookingDetail.ReferenceDetail.Reference1, reference = directBookingDetail.FrayteNumber + "-" + directBookingDetail.ReferenceDetail.Reference1, contact = new Contact { name = directBookingDetail.ShipTo.FirstName + " " + directBookingDetail.ShipTo.LastName, email = string.IsNullOrEmpty(directBookingDetail.ShipTo.Email) ? "*****@*****.**" : directBookingDetail.ShipTo.Email, phoneNumber = directBookingDetail.ShipTo.Phone } }, pickupPoint = null }, product = new Product() { id = "PA_DOREN", customerNumber = directBookingDetail.CustomerRateCard.NetworkCode, services = null, customsDeclaration = directBookingDetail.CustomInfo.CatagoryOfItemExplanation, }, purchaseOrder = null, correlationId = null, packages = packages }; bringRequest.consignments.Add(consign); GetXMLFromRequestObject(bringRequest); return(bringRequest); }
public IHttpActionResult UpdateConsignment(ConsignmentModel model) { var data = consignment.UpdateConsignment(model); return(Ok(data)); }
public bool SaveConsignment(ConsignmentModel model) { try { //var data = tRSEntities4.ConsignmentOperations.Where(x => x.id == model.id && x.isActive == true).FirstOrDefault(); if (model != null) { ConsignmentOperation operation = new ConsignmentOperation { cndate = model.cndate, expectedDelivery = model.expectedDelivery, from = model.from, to = model.to, godownNo = model.godownNo, paymentType = model.paymentType, actualWeight = model.actualWeight, consignee = model.consignee, cnNo = model.cnNo, deliveryBranch = model.deliveryBranch, virtualGoddownNo = model.virtualGoddownNo, consignorDetails = model.consignorDetails, consignor = model.consignor, agentName = model.agentName, agentDetails = model.agentDetails, bookingType = model.bookingType, deliveryType = model.deliveryType, modeOfTransport = model.modeOfTransport, invoiceNo = model.invoiceNo, invoiceValue = model.invoiceValue, consignorInvoice = model.consignorInvoice, freightBasis = model.freightBasis, ftl = model.ftl, isCcAttached = model.isCcAttached, isCod = model.isCod, chargeWeight = model.chargeWeight, freightRate = model.freightRate, privateMark = model.privateMark, insuredBy = model.insuredBy, freight = model.freight, surcharge = model.surcharge, hamaliCharge = model.hamaliCharge, localCartages = model.localCartages, doorDeliveryCharge = model.doorDeliveryCharge, statisticalCharges = model.statisticalCharges, miscellaneousCharges = model.miscellaneousCharges, godownCharges = model.godownCharges, cod = model.cod, financeEffect = model.financeEffect, isActive = true, }; tRSEntities4.ConsignmentOperations.Add(operation); tRSEntities4.SaveChanges(); return(true); } else { return(false); } } catch (Exception e) { throw e; } }
/// <summary> /// Method to call APIs and read response asynchronously /// </summary> /// <param name="api">string api initial</param> /// <param name="carrierQuoteList">CarrierQuoteModel list object</param> /// <returns></returns> private async Task ExecuteUrlAsync(string api, IList <CarrierQuoteModel> carrierQuoteList) { switch (api.ToLower()) { case "getcarrier1quote": List <DimensionModel> dimension = new List <DimensionModel>(); dimension.Add(new DimensionModel() { Height = 20, Width = 20, NoOfCartons = 5 }); dimension.Add(new DimensionModel() { Height = 10, Width = 10, NoOfCartons = 10 }); AddressModel address = new AddressModel() { Address = "Test Address", City = "Test City", State = "Test State", ZipCode = "6a7f88", ContactNumber = "1111111" }; var payload = new WarehouseModel() { ContactAddress = address, WarehouseAddress = address, PackageDimensions = dimension }; HttpResponseMessage response = await httpClient.PostAsync(_configuration.GetValue <string>("BaseUrl") + api, new StringContent(JsonConvert.SerializeObject(payload), Encoding.UTF8, "application/json"), cancelTokenSource.Token); response.EnsureSuccessStatusCode(); string responseBody = await response.Content.ReadAsStringAsync(); var jObjResult = JObject.Parse(responseBody); carrierQuoteList.Add(new CarrierQuoteModel() { Name = api, Amount = float.Parse(jObjResult["total"].ToString()) }); break; case "getcarrier2quote": List <DimensionModel> cartons = new List <DimensionModel>(); cartons.Add(new DimensionModel() { Height = 30, Width = 30, NoOfCartons = 10 }); cartons.Add(new DimensionModel() { Height = 10, Width = 10, NoOfCartons = 20 }); AddressModel addressCarrier2 = new AddressModel() { Address = "Test Address", City = "Test City", State = "Test State", ZipCode = "6a7f88", ContactNumber = "1111111" }; var payloadCarrier2 = new ConsignmentModel() { Consignee = addressCarrier2, Consignor = addressCarrier2, Cartons = cartons }; HttpResponseMessage responseCarrier2 = await httpClient.PostAsync(_configuration.GetValue <string>("BaseUrl") + api, new StringContent(JsonConvert.SerializeObject(payloadCarrier2), Encoding.UTF8, "application/json"), cancelTokenSource.Token); responseCarrier2.EnsureSuccessStatusCode(); string responseBodyCarrier2 = await responseCarrier2.Content.ReadAsStringAsync(); var jObjResultCarrier2 = JObject.Parse(responseBodyCarrier2); carrierQuoteList.Add(new CarrierQuoteModel() { Name = api, Amount = float.Parse(jObjResultCarrier2["amount"].ToString()) }); break; case "getcarrier3quote": string xmlPayload = "<QuoteModel xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://schemas.datacontract.org/2004/07/HomeProject.Model\">" + "<Destination> <Address>Test Source</Address><City>Test</City><ContactNumber>333333</ContactNumber><State>Test</State><ZipCode>86988h</ZipCode></Destination>" + "<Packages>" + "<DimensionModel><Height>40</Height><NoOfCartons>5</NoOfCartons><Width>40</Width></DimensionModel>" + "<DimensionModel><Height>20</Height><NoOfCartons>10</NoOfCartons><Width>20</Width></DimensionModel>" + "<DimensionModel><Height>10</Height><NoOfCartons>15</NoOfCartons><Width>10</Width></DimensionModel>" + "</Packages>" + "<Source><Address>Test Source</Address><City>Test</City><ContactNumber>333333</ContactNumber><State>Test</State><ZipCode>86988h</ZipCode></Source>" + "</QuoteModel>"; HttpResponseMessage responseCarrier3 = await httpClient.PostAsync(_configuration.GetValue <string>("BaseUrl") + api, new StringContent(xmlPayload, Encoding.UTF8, "application/xml"), cancelTokenSource.Token); responseCarrier3.EnsureSuccessStatusCode(); string responseBodyCarrier3 = await responseCarrier3.Content.ReadAsStringAsync(); XDocument xdoc = new XDocument(); xdoc = XDocument.Parse(responseBodyCarrier3); carrierQuoteList.Add(new CarrierQuoteModel() { Name = api, Amount = float.Parse(xdoc.Root.Value) }); break; } }
public List <ConsignmentModel> GetConsignmentModels() { try { List <ConsignmentModel> consignments = new List <ConsignmentModel>(); var data = tRSEntities4.ConsignmentOperations.Where(x => x.isActive == true).ToList(); foreach (var item in data) { ConsignmentModel model = new ConsignmentModel { id = item.id, cndate = item.cndate, expectedDelivery = item.expectedDelivery, from = item.from, to = item.to, godownNo = item.godownNo, paymentType = item.paymentType, actualWeight = item.actualWeight, consignee = item.consignee, cnNo = item.cnNo, deliveryBranch = item.deliveryBranch, virtualGoddownNo = item.virtualGoddownNo, consignorDetails = item.consignorDetails, consignor = item.consignor, agentName = item.agentName, agentDetails = item.agentDetails, bookingType = item.bookingType, deliveryType = item.deliveryType, modeOfTransport = item.modeOfTransport, invoiceNo = item.invoiceNo, invoiceValue = item.invoiceValue, consignorInvoice = item.consignorInvoice, freightBasis = item.freightBasis, ftl = item.ftl, isCcAttached = item.isCcAttached, isCod = item.isCod, chargeWeight = item.chargeWeight, freightRate = item.freightRate, privateMark = item.privateMark, insuredBy = item.insuredBy, freight = item.freight, surcharge = item.surcharge, hamaliCharge = item.hamaliCharge, localCartages = item.localCartages, doorDeliveryCharge = item.doorDeliveryCharge, statisticalCharges = item.statisticalCharges, miscellaneousCharges = item.miscellaneousCharges, godownCharges = item.godownCharges, cod = item.cod, financeEffect = item.financeEffect, isActive = true, godownName = tRSEntities4.GodownMasters.Where(x => x.id == item.godownNo).Select(x => x.godownCode).FirstOrDefault(), fromName = tRSEntities4.BranchMasters.Where(x => x.id == item.from).Select(x => x.branchName).FirstOrDefault(), }; consignments.Add(model); } return(consignments); } catch (Exception e) { throw e; } }