Esempio n. 1
0
        public async Task <IActionResult> Create()
        {
            var measureTypes = await this.measureTypeService.GetAllDeleted();

            var model = new CreateMeasureTypeViewModel()
            {
                MeasureTypes = measureTypes
            };

            return(View(model));
        }
Esempio n. 2
0
 public async Task <IActionResult> Create(CreateMeasureTypeViewModel model)
 {
     if (!this.ModelState.IsValid)
     {
         TempData["Error-Message"] = "Error while trying to create a new measure type";
         return(this.RedirectToAction("Index", "Home", new { area = "Administration" }));
     }
     try
     {
         await this.measureTypeService.Create(model.MeasureUnit, model.SuitableSensorType);
     }
     catch (EntityAlreadyExistsException e)
     {
         TempData["Error-Message"] = e.Message;
         return(this.RedirectToAction("Create", "MeasureType", new { area = "Administration" }));
     }
     this.TempData["Success-Message"] = $"You successfully registered {model.SuitableSensorType} as a sensor type!";
     return(this.RedirectToAction("Create", "MeasureType", new { area = "Administration" }));
 }