コード例 #1
0
        public async Task<ActionResult> Create(FurnitureViewModel furnitureModel, CancellationToken cancellationToken) {
            try {
                logger.Debug("ModelState is valid: {0}", ModelState.IsValid);
                logger.Debug("Furniture: {0}", furnitureModel.Furniture);
                if (ModelState.IsValid) {
                    await service.CreateAsync(furnitureModel, HttpContext, cancellationToken);
                    return RedirectToAction("Index");
                }
            }
            catch (Exception ex) {
                logger.Error(ex, ex.Message);
                ModelState.AddModelError("", ex.Message);
            }

            return View(await service.PrepareCreateAsync(cancellationToken));
        }
コード例 #2
0
        public async Task<ActionResult> Edit(FurnitureViewModel furnitureModel, CancellationToken cancellationToken) {
            try {              
                logger.Debug("ModelState is valid: {0}", ModelState.IsValid);
                logger.Debug("Furniture: {0}", furnitureModel.Furniture);
                logger.Debug("Files: {0}", furnitureModel.Files);
                logger.Debug("CheckedImages: {0}", furnitureModel.CheckedImages);

                if (ModelState.IsValid) {
                    await service.EditAsync(furnitureModel, HttpContext, cancellationToken);
                    return RedirectToAction("Index");
                }
            }
            catch (Exception ex) {
                ModelState.AddModelError("", ex.Message);
            }

            return View(await service.PrepareEditAsync(furnitureModel.Furniture.ID, cancellationToken));
        }