public ActionResult PlaceOrder(int id) { if (Session["Authenticated"] != null) { // following information are required when gettin the order back from the client RequestQuotationViewModel model = new RequestQuotationViewModel(); model.Enterprise = db.Enterprises.Find(id); model.PaymentMethod = new List <PaymentMethod> { new PaymentMethod { PaymentMethodName = "Cash" }, new PaymentMethod { PaymentMethodName = "Cheque" } }; model.DeliveryMode = new List <DeliveryMethod> { new DeliveryMethod { DeliveryModeName = "Store Pickup" }, new DeliveryMethod { DeliveryModeName = "Courier" } }; // filling out the account information string userEmail = Session["UserEmail"].ToString(); Account account = db.Accounts.Where(a => a.Email2 == userEmail).First(); model.Account = account; return(View(model)); } else { return(RedirectToAction("Login", "Account", new { area = "Accounts" })); } }
public IHttpActionResult Save([FromBody] RequestQuotationViewModel model) { try { if (model == null) { return(NotFound()); } var quotation = new RequestQuotation { Id = model.Id, ServiceRequestId = model.ServiceRequestId, AgentId = model.AgentId, QuotationTemplateId = model.QuotationTemplateId, QuotationText = model.QuotationText, Premimum = Convert.ToDecimal(model.Premimum.Replace(",", String.Empty)), Status = (int)Constant.QuotationStatus.Initial, Cover = Convert.ToDecimal(model.Cover.Replace(",", String.Empty)) }; using (AppDBContext context = new AppDBContext()) { long quoteId = new RequestQuotationRepository(context).Save(quotation); new AgentServiceRequestRepository(context).UpdateResponseTime(model.ServiceRequestId, model.AgentId); var userRepo = new UserRepository(context); var request = new ServiceRequestRepository(context).GetById(model.ServiceRequestId); var agentProfile = new UserProfileRepository(context).GetByUserId(model.AgentId); var agent = userRepo.GetByUserId(model.AgentId); var agentName = agent.Name; var company = agent.Company.Name; if (agentProfile != null) { agentName = agentProfile.FirstName + " " + agentProfile.LastName; } MessageModel message = new MessageModel { MessageText = "Quotation Sent by: " + agentName + "\n" + company, RequestId = model.ServiceRequestId, SenderId = model.AgentId, RecieverId = request.UserId, QuotationId = quoteId }; AddMessage(message, context); new NotificationRepository(context).Add( message.RecieverId, (int)Constant.NotificationType.Quotation, message.QuotationId, ConfigurationHelper.NOTIFICATION_TITLE, Constant.Notification.NEW_QUOTATION_TEXT); } } catch (Exception ex) { Logger.Log(typeof(QuotationController), ex.Message + ex.StackTrace, LogType.ERROR); return(InternalServerError()); } return(Ok()); }
public IHttpActionResult GetByIdFromBuyer(long Id) { RequestQuotationViewModel model = null; try { using (AppDBContext context = new AppDBContext()) { var quote = new RequestQuotationRepository(context).GetById(Id); if (quote != null) { model = new RequestQuotationViewModel { Id = quote.Id, ServiceRequestId = quote.ServiceRequestId, QuotationTemplateId = quote.QuotationTemplateId, Premimum = quote.Premimum?.ToString("#,##0.00"), Cover = quote.Cover?.ToString("#,##0.00"), AgentId = quote.AgentId, AgentName = quote.Agent?.Name, AgentContact = quote.Agent?.UserName, CompanyId = quote.Agent?.CompanyId ?? 0, CompanyName = quote.Agent?.Company?.Name, QuotationTemplateName = quote.QuotationTemplate.Name, QuotationText = quote.QuotationText, Status = quote.Status ?? 0, ServiceRequestCode = quote.ServiceRequest.Code, ClaimType = quote.ServiceRequest.ClaimType, VehicleNo = quote.ServiceRequest.VehicleNo, VehicleValue = quote.ServiceRequest.VehicleValue, IsExpired = quote.IsExpired ?? false }; if (quote.ServiceRequest.Status == (int)Constant.ServiceRequestStatus.Closed || quote.ServiceRequest.Status == (int)Constant.ServiceRequestStatus.Expired) { model.Status = (int)Constant.QuotationStatus.Closed; } var messageThread = new MessageThreadRepository(context).GetByAgentAndRequest(model.AgentId, model.ServiceRequestId); if (messageThread != null) { model.ThreadId = messageThread.Id; } new RequestQuotationRepository(context).UpdateToChecked(quote.Id); } } return(Ok(model)); } catch (Exception ex) { Logger.Log(typeof(QuotationController), ex.Message + ex.StackTrace, LogType.ERROR); return(InternalServerError()); } }
public ActionResult RequestQuote(string id) { RequestQuotationViewModel model = new RequestQuotationViewModel(); model.Wholesaler = db.Wholesalers.Where(w => w.Id == id).Single <Wholesaler>(); string retailerId = User.Identity.GetUserId(); model.Retailer = db.Retailers.Where(r => r.Id == retailerId).Single <Retailer>(); return(View(model)); }
/// <summary> /// This page facilitates the user to enter information about the quotation /// Except product information /// </summary> /// <param name="id"></param> /// <returns></returns> public ActionResult RequestQuotation(int id) { if (Session["Authenticated"] != null) { // following information are required when gettin the order back from the client RequestQuotationViewModel model = new RequestQuotationViewModel(); model.Enterprise = db.Enterprises.Find(id); model.PaymentMethod = new List <PaymentMethod> { new PaymentMethod { PaymentMethodName = "Cash" }, new PaymentMethod { PaymentMethodName = "Cheque" } }; model.DeliveryMode = new List <DeliveryMethod> { new DeliveryMethod { DeliveryModeName = "Store Pickup" }, new DeliveryMethod { DeliveryModeName = "Courier" } }; // filling out the account information string userEmail = Session["UserEmail"].ToString(); Account account = db.Accounts.Where(a => a.Email2 == userEmail).First(); model.Account = account; // get all the enterprises this account has access to try { Integrator integrator = new Integrator(); string response = integrator.getResponseMessage("/api/Enterprises/GetEnterpriseAccounts/" + account.Id); // please see the method doc List <Enterprise> myEnterprises = parseStringListToEnterprise(response); model.MyEnterprises = myEnterprises; } catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex); } return(View(model)); } else { return(RedirectToAction("Login", "Account", new { area = "Accounts" })); } }
public IActionResult Index() { // obtener los tipos de camiones (registro de choferes) repositoryTruckType.setResource("truck/"); var registerCarrierVM = new RegisterCarrierViewModel { trucksTypes = repositoryTruckType.getAll() }; ViewData["truckTypes"] = registerCarrierVM; // obtener los servicios para Delta X (solicitud de cotizaciones) repositoryServiceType.setResource("service/delta_x"); repositoryUnitMeasurement.setResource("unitMeasurement/typeName/storage_capacity"); var requestQuotationVM = new RequestQuotationViewModel { servicesTypes = repositoryServiceType.getAll(), umsStorageCapacity = repositoryUnitMeasurement.getAll(), }; repositoryUnitMeasurement.setResource("unitMeasurement/typeName/storage_time"); requestQuotationVM.umsStorageTime = repositoryUnitMeasurement.getAll(); // guardar en los datos temporales ViewData["registerCarrier"] = registerCarrierVM; ViewData["requestQuotation"] = requestQuotationVM; //ViewData["serviceTypes"] = repositoryServiceType.getAll(); // obtener las unidades de medida para capacidad de almacenamiento (solicitud de cotizaciones) //ViewData["unitMeasurementStorageCapacity"] = repositoryUnitMeasurement.getAll(); // obtener las unidades de medida para tiempo de almacenamiento (solicitud de cotizaciones) //ViewData["unitMeasurementStorageTime"] = repositoryUnitMeasurement.getAll(); return(View()); }