Esempio n. 1
0
        public async Task <IActionResult> Edit(LossAdjusterViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    LossAdjuster lossAdjuster = new LossAdjuster();
                    lossAdjuster = viewModel.LossAdjuster;
                    _context.Update(lossAdjuster);
                    await _context.SaveChangesAsync();

                    var payeeParams = new object[] { lossAdjuster.ID, lossAdjuster.Name };
                    await _context.Database.ExecuteSqlCommandAsync(
                        "UPDATE Payee SET Name = {0} WHERE PayeeItemID = {1}",
                        parameters : payeeParams);

                    return(RedirectToAction("Index", new { payeeclassId = viewModel.LossAdjuster.PayeeClassID }));
                }
                catch (DbUpdateException ex)
                {
                    var errorMsg = ex.InnerException.Message.ToString();

                    viewModel.ErrMsg = errorMsg;
                    ModelState.AddModelError(string.Empty, viewModel.ErrMsg);
                }
            }
            return(View(viewModel));
        }
Esempio n. 2
0
        // GET: LossAdjusters/Edit/5
        public async Task <IActionResult> Edit(Guid Id)
        {
            LossAdjusterViewModel viewModel = new LossAdjusterViewModel
            {
                LossAdjuster = await _context.LossAdjusters.SingleOrDefaultAsync(m => m.ID == Id)
            };

            return(View(viewModel));
        }
Esempio n. 3
0
        public async Task <IActionResult> Create(LossAdjusterViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                LossAdjuster lossAdjuster = new LossAdjuster();
                lossAdjuster    = viewModel.LossAdjuster;
                lossAdjuster.ID = Guid.NewGuid();
                _context.Add(lossAdjuster);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index", new { payeeclassId = viewModel.LossAdjuster.PayeeClassID }));
            }
            return(View(viewModel));
        }
Esempio n. 4
0
        // GET: LossAdjusters/Create
        public IActionResult Create(int payeeClassId)
        {
            LossAdjuster lossAdjuster = new LossAdjuster
            {
                PayeeClassID = payeeClassId
            };

            LossAdjusterViewModel viewModel = new LossAdjusterViewModel
            {
                LossAdjuster = lossAdjuster
            };

            return(View(viewModel));
        }