public ActionResult CellEditInsert([FromBody] CRUDModel <Client> client) { client.Value.ID = Guid.NewGuid(); _context.Add(client.Value); _context.SaveChanges(); return(Json(client)); }
public ActionResult CellEditInsert([FromBody] CRUDModel <Coverage> coverage) { coverage.Value.ID = Guid.NewGuid(); _context.Add(coverage.Value); _context.SaveChanges(); return(Json(coverage)); }
public async Task <IActionResult> AddRiskClaimDocuments(string riskId, string[] claimdocuments) { int selectedRiskId = int.Parse(riskId); int ro = claimdocuments.Count(); RiskClaimDocument riskclaimdocument = new RiskClaimDocument(); for (int i = 0; i < ro; i++) { riskclaimdocument.RiskID = selectedRiskId; riskclaimdocument.ClaimDocumentID = Guid.Parse(claimdocuments[i].ToString()); _context.Add(riskclaimdocument); await _context.SaveChangesAsync(); } var updatedclaimdocuments = _context.ClaimDocuments .Where(i => !i.RiskClaimDocuments .Any(r => r.RiskID == selectedRiskId)) .ToList(); var updatedriskclaimdocuments = _context.RiskClaimDocuments .Include(r => r.ClaimDocument) .Where(r => r.RiskID == selectedRiskId) .ToList().Select(r => new SelectListItem { Value = r.ClaimDocumentID.ToString(), Text = r.ClaimDocument.Name }); return(Json(new { updatedclaimdocuments, updatedriskclaimdocuments })); }
public async Task <IActionResult> Create(ThirdPartyViewModel viewModel) { var idNumber = viewModel.ThirdParty.IDNumber; try { if (ModelState.IsValid) { ThirdParty thirdParty = new ThirdParty(); thirdParty = viewModel.ThirdParty; thirdParty.ID = Guid.NewGuid(); _context.Add(thirdParty); await _context.SaveChangesAsync(); return(RedirectToAction("Index", new { payeeclassId = viewModel.ThirdParty.PayeeClassID })); } } catch (DbUpdateException ex) { var errorMsg = ex.InnerException.Message.ToString(); if (errorMsg.Contains("IX_ThirdParty_IDNumber")) { viewModel.ErrMsg = $"Duplicate ID Number {idNumber} exists."; } else { viewModel.ErrMsg = errorMsg; } ModelState.AddModelError(string.Empty, viewModel.ErrMsg); } return(View(viewModel)); }
public async Task <IActionResult> Create(ContainerViewModel viewModel) { try { if (ModelState.IsValid) { Container container = new Container(); container = viewModel.Container; container.ID = Guid.NewGuid(); container.AddedBy = Guid.Parse(User.FindFirstValue(ClaimTypes.NameIdentifier)); container.DateAdded = DateTime.Now; _context.Add(container); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } } catch (DbUpdateException /* ex */) { //Log the error (uncomment ex variable name and write a log. ModelState.AddModelError("", "Unable to save changes. " + "Try again, and if the problem persists " + "see your system administrator."); } return(View(viewModel)); }
public async Task <IActionResult> Create(LoadFormatViewModel viewModel) { FileTypes[] values = (FileTypes[])Enum.GetValues(typeof(FileTypes)); if (ModelState.IsValid) { LoadFormat loadFormat = new LoadFormat(); loadFormat = viewModel.LoadFormat; loadFormat.ID = Guid.NewGuid(); loadFormat.ProductID = viewModel.ProductID; _context.Add(loadFormat); await _context.SaveChangesAsync(); // Populate Format Types var loadFormatId = loadFormat.ID; PopulateFormatTypes(loadFormatId); return(RedirectToAction("Index", new { productId = viewModel.ProductID })); } var list = (from value in values select new SelectListItem() { Value = ((int)value).ToString(), Text = value.ToString() }).ToList(); viewModel.FileTypeList = new SelectList(list, "Value", "Text"); return(View(viewModel)); }
public async Task <IActionResult> Create(ContentViewModel viewModel) { try { if (ModelState.IsValid) { // Check that Start Date and End Date are within Policy Cover Start and Cover End Date Guid policyId = viewModel.PolicyID; viewModel.ErrMsg = string.Empty; var startDate = viewModel.Content.StartDate; var endDate = viewModel.Content.EndDate; CompareDates compareDates = new CompareDates(_context); if (compareDates.CompareStartDate(policyId, startDate) < 0) { viewModel.ErrMsg = $"Start Date cannot be earlier than Policy Cover Start Date"; ModelState.AddModelError(string.Empty, viewModel.ErrMsg); } if (compareDates.CompareEndDate(policyId, endDate) > 0) { viewModel.ErrMsg = $"End Date cannot be later than Policy Cover End Date"; ModelState.AddModelError(string.Empty, viewModel.ErrMsg); } if (string.IsNullOrEmpty(viewModel.ErrMsg)) { Content content = viewModel.Content; content.ID = Guid.NewGuid(); content.PolicyID = policyId; _context.Add(content); await _context.SaveChangesAsync(); return(RedirectToAction("PolicyRisks", "Policies", new { productId = viewModel.ProductID, clientId = viewModel.ClientID, policyId = viewModel.PolicyID })); } } } catch (DbUpdateException ex) { var errorMsg = ex.InnerException.Message.ToString(); viewModel.ErrMsg = errorMsg; ModelState.AddModelError(string.Empty, viewModel.ErrMsg); } viewModel.ResidenceTypeList = new SelectList(await _context.ResidenceTypes .AsNoTracking() .ToListAsync(), "ID", "Name", viewModel.Content.ResidenceTypeID); viewModel.RoofTypeList = new SelectList(await _context.RoofTypes .AsNoTracking() .ToListAsync(), "ID", "Name", viewModel.Content.RoofTypeID); viewModel.WallTypeList = new SelectList(await _context.WallTypes .AsNoTracking() .ToListAsync(), "ID", "Name", viewModel.Content.WallTypeID); return(View(viewModel)); }
public async Task <IActionResult> Create([Bind("ID,PolicyID,InvoiceDate,Status")] Invoice invoice) { if (ModelState.IsValid) { _context.Add(invoice); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(invoice)); }
public async Task <IActionResult> Create(AddressViewModel viewModel) { if (ModelState.IsValid) { Address address = new Address(); AddressAssignment addressassignment = new AddressAssignment(); address = viewModel.Address; address.ID = Guid.NewGuid(); _context.Add(address); await _context.SaveChangesAsync(); addressassignment.ItemID = viewModel.ItemID; addressassignment.AddressID = address.ID; _context.Add(addressassignment); await _context.SaveChangesAsync(); return(RedirectToAction("Details", viewModel.ControllerName, new { id = viewModel.ItemID })); } return(View(viewModel)); }
public async Task <IActionResult> Create([Bind("ID,Name")] ClientType clientType) { if (ModelState.IsValid) { _context.Add(clientType); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(clientType)); }
public async Task <IActionResult> Create([Bind("ID,Name")] PayeeClass payeeClass) { if (ModelState.IsValid) { _context.Add(payeeClass); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(payeeClass)); }
public async Task <IActionResult> Create([Bind("BulkNumber,AddedBy,BulkDate,DateAdded,RecordCount,TableName")] BulkHandleGenerator bulkHandleGenerator) { if (ModelState.IsValid) { _context.Add(bulkHandleGenerator); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(bulkHandleGenerator)); }
public async Task <IActionResult> Create([Bind("ID,Name")] IncomeClass incomeClass) { if (ModelState.IsValid) { incomeClass.ID = Guid.NewGuid(); _context.Add(incomeClass); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(incomeClass)); }
public async Task <IActionResult> Create([Bind("ID,AccountCode,Description,IncomeOrExpense")] AccountChart accountChart) { if (ModelState.IsValid) { accountChart.ID = Guid.NewGuid(); _context.Add(accountChart); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(accountChart)); }
public async Task <IActionResult> Create([Bind("ID,Name")] Component component) { if (ModelState.IsValid) { component.ID = Guid.NewGuid(); _context.Add(component); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(component)); }
public async Task <IActionResult> Create([Bind("ID,DialingCode,ISOCode,ISOCurrency,Name,Tax")] Country country) { if (ModelState.IsValid) { country.ID = Guid.NewGuid(); _context.Add(country); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(country)); }
public async Task <IActionResult> Create([Bind("ID,Name")] Affected affected) { if (ModelState.IsValid) { affected.ID = Guid.NewGuid(); _context.Add(affected); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(affected)); }
public async Task <IActionResult> Create([Bind("ID,Description,Name")] Region region) { if (ModelState.IsValid) { region.ID = Guid.NewGuid(); _context.Add(region); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(region)); }
public async Task <IActionResult> Create([Bind("ID,Divisor,Name")] PolicyFrequency policyFrequency) { if (ModelState.IsValid) { policyFrequency.ID = Guid.NewGuid(); _context.Add(policyFrequency); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(policyFrequency)); }
public async Task <IActionResult> Create([Bind("ID,IsUpdatable,Name")] PolicyStatus policyStatus) { if (ModelState.IsValid) { policyStatus.ID = Guid.NewGuid(); _context.Add(policyStatus); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(policyStatus)); }
public async Task <IActionResult> Create([Bind("ID,Name")] WallType wallType) { if (ModelState.IsValid) { wallType.ID = Guid.NewGuid(); _context.Add(wallType); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(wallType)); }
public async Task <IActionResult> AddBankAccount(PayeeBankAccountViewModel viewModel) { if (ModelState.IsValid) { BankAccount bankaccount = viewModel.BankAccount; PayeeBankAccount payeebankaccount = new PayeeBankAccount(); bankaccount.ID = Guid.NewGuid(); _context.Add(bankaccount); await _context.SaveChangesAsync(); payeebankaccount.BankAccountID = bankaccount.ID; payeebankaccount.PayeeID = viewModel.PayeeID; _context.Add(payeebankaccount); await _context.SaveChangesAsync(); //Guid payeeItemId = GetPayeeItemId(payeebankaccount.PayeeID); return(RedirectToAction("PayeeBankAccounts", new { payeeId = viewModel.PayeeID })); } return(View(viewModel)); }
public async Task <IActionResult> Create([Bind("ID,MotorMakeID,Name")] MotorModel motorModel) { if (ModelState.IsValid) { motorModel.ID = Guid.NewGuid(); _context.Add(motorModel); await _context.SaveChangesAsync(); return(RedirectToAction("Index", new { motormakeid = motorModel.MotorMakeID })); } ViewData["MotorMakeID"] = motorModel.MotorMakeID; return(View(motorModel)); }
public async Task <IActionResult> Create([Bind("ID,Name")] PaymentType paymentType) { if (ModelState.IsValid) { Random rnd = new Random(); paymentType.ID = rnd.Next(6, 9); _context.Add(paymentType); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(paymentType)); }
public async Task <IActionResult> Create([Bind("ID,Reference,PayableDate,PaymentTypeID,Amount,BatchNumber,Void,VoidReason,Remarks,PayableExportID")] Payable payable) { if (ModelState.IsValid) { payable.ID = Guid.NewGuid(); _context.Add(payable); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewData["PayableExportID"] = new SelectList(_context.PayableExports, "ID", "Name", payable.PayableExportID); return(View(payable)); }
public async Task <IActionResult> Create([Bind("ID,ColumnLength,Delimiter,FieldName,LoadFormatID,IsKey,Position,TableName")] FormatType formatType) { if (ModelState.IsValid) { formatType.ID = Guid.NewGuid(); _context.Add(formatType); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewData["LoadFormatID"] = new SelectList(_context.LoadFormats, "ID", "ID", formatType.LoadFormatID); return(View(formatType)); }
public async Task <IActionResult> Create(ClaimDocumentViewModel viewModel) { if (ModelState.IsValid) { ClaimDocument claimDocument = new ClaimDocument(); claimDocument = viewModel.ClaimDocument; claimDocument.ID = Guid.NewGuid(); _context.Add(claimDocument); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(viewModel)); }
public async Task <IActionResult> Create(TracingAgentViewModel viewModel) { if (ModelState.IsValid) { TracingAgent tracingAgent = new TracingAgent(); tracingAgent = viewModel.TracingAgent; tracingAgent.ID = Guid.NewGuid(); _context.Add(tracingAgent); await _context.SaveChangesAsync(); return(RedirectToAction("Index", new { payeeclassId = viewModel.TracingAgent.PayeeClassID })); } return(View(viewModel)); }
public async Task <IActionResult> Create(BankViewModel viewModel) { if (ModelState.IsValid) { Bank bank = new Bank(); bank = viewModel.Bank; bank.ID = Guid.NewGuid(); _context.Add(bank); await _context.SaveChangesAsync(); return(RedirectToAction("Index", new { payeeclassId = viewModel.Bank.PayeeClassID })); } return(View(viewModel)); }
public async Task <IActionResult> Create(InsurerViewModel viewModel) { if (ModelState.IsValid) { Insurer insurer = new Insurer(); insurer = viewModel.Insurer; insurer.ID = Guid.NewGuid(); _context.Add(insurer); await _context.SaveChangesAsync(); return(RedirectToAction("Index", new { payeeclassId = viewModel.Insurer.PayeeClassID })); } return(View(viewModel)); }