public IHttpActionResult Get(int id) { CustomApplicationDbContext db = new CustomApplicationDbContext(); IQueryable <Lookup> itemTypes = db.Lookups.Where(l => l.Type.Description == EnumHelper.LookupTypes.Category.ToString()); IQueryable <Lookup> quoteRequestStatusTypes = db.Lookups.Where(l => l.Type.Description == EnumHelper.LookupTypes.QuoteRequestStatus.ToString()); IQueryable <Tenant> tenants = db.Tenants.Where(t => t.Users.Where(u => u.UserName == User.Identity.Name).Any()); Mapper.CreateMap <Tenant, TenantViewModel>(); var listOfTenantViewModel = Mapper.Map <IEnumerable <Tenant>, IEnumerable <TenantViewModel> >(tenants.ToList()); if (id == -1) { QuoteRequestViewModel quoteRequestTemplate = new QuoteRequestViewModel(); quoteRequestTemplate.ItemTypes = itemTypes; quoteRequestTemplate.Tenants = listOfTenantViewModel; quoteRequestTemplate.QuoteRequestStatuses = quoteRequestStatusTypes; quoteRequestTemplate.SelectedQuoteRequestStatus = quoteRequestStatusTypes.FirstOrDefault(x => x.Description == "Pending"); return(Ok(quoteRequestTemplate)); } QuoteRequest quoteRequest = QuoteRequestService.GetSingleQuote(id); Mapper.CreateMap <QuoteRequest, QuoteRequestViewModel>(); QuoteRequestViewModel quoteRequestViewModel = Mapper.Map <QuoteRequestViewModel>(quoteRequest); quoteRequestViewModel.ItemTypes = itemTypes.ToList(); quoteRequestViewModel.QuoteRequestStatuses = quoteRequestStatusTypes.ToList(); quoteRequestViewModel.SelectedItemType = quoteRequest.Category; quoteRequestViewModel.SelectedQuoteRequestStatus = quoteRequest.QuoteRequestStatus; quoteRequestViewModel.Tenants = listOfTenantViewModel; quoteRequestViewModel.CanChangeStatus = User.IsInRole("Admin") ? true : false; return(Ok(quoteRequestViewModel)); //return Json<QuoteRequestViewModel>(quoteRequestViewModel); }
public async Task <IActionResult> Get([FromQuery] Guid key) { QuoteRequestViewModel quote = await GetQuoteRequestAsync(key); if (quote == null) { return(StatusCode(404)); } return(Ok(quote)); }
public ActionResult New() { var viewModel = new QuoteRequestViewModel(); viewModel.Bankers = _bankerService.GetBankers(); viewModel.Products = _productService.GetProducts(); viewModel.BankersList = new Dictionary<string, string>(); foreach (var banker in viewModel.Bankers) { viewModel.BankersList.Add(banker.BankerUserId,banker.Name.FullName); } return View(viewModel); }
public IHttpActionResult Post([FromBody] QuoteRequestViewModel value) { if (ModelState.IsValid) { Mapper.CreateMap <QuoteRequestViewModel, QuoteRequest>(); QuoteRequest quoteRequestToCreate = Mapper.Map <QuoteRequest>(value); quoteRequestToCreate.TenantId = value.SelectedTenant.TenantId; quoteRequestToCreate.CategoryId = value.SelectedItemType.LookupId; quoteRequestToCreate.QuoteRequestStatusId = value.SelectedQuoteRequestStatus.LookupId; QuoteRequestService.SaveQuoteRequest(quoteRequestToCreate); } else { //IEnumerable<string> errors = ModelState.Values.SelectMany(x => x.Errors.Select(e => e.ErrorMessage)); return(BadRequest(ModelState)); } return(Ok("success")); //return CreatedAtRoute("DefaultApi", "success", value); }
public async Task <IActionResult> Post([FromBody] QuoteRequestViewModel value) { var newQuateRequest = new InsuranceQuotingRequest() { Key = Guid.NewGuid(), Customer = value.Customer, Vehicle = value.Vehicle, QuoteProcessStatus = new QuoteProcessStatus() { Status = QuoteStatus.Pendding } }; await _repository.AddOrUpdateAsync(newQuateRequest); _eventBus.Publish(new QuoteRequestedIntegrationEvent( newQuateRequest.Key )); _cache.Set(newQuateRequest.Key, newQuateRequest); return(Ok(newQuateRequest.Key)); }
public ActionResult Update(QuoteRequestViewModel model) { throw new NotImplementedException(); }