Ejemplo n.º 1
0
        public async Task <ActionResult> Edit(Guid id, EditUnitOfMeasureTypeViewModel request)
        {
            if (!ModelState.IsValid)
            {
                Alert("Invalid Request", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime));
                return(View());
            }
            if (!id.Equals(request.Id))
            {
                Alert("Invalid Request", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime));
                return(View());
            }
            try
            {
                var unitOfMeasureTypeUpdateRequest = new UpdateUnitOfMeasureTypeRequest {
                    Id = request.Id, Name = request.Name, Description = request.Description
                };
                var result = await _unitOfMeasureTypeService.Update(id, unitOfMeasureTypeUpdateRequest);

                if (!result.Success)
                {
                    Alert($"Error: {result.Message}", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime));
                    return(View());
                }

                Alert($"Unit Of Measure Type Updated Successfully", NotificationType.success, Int32.Parse(_appConfig.Value.NotificationDisplayTime));
                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                Alert($"Error Occurred While processing the request", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime));
                return(View());
            }
        }
Ejemplo n.º 2
0
        // GET: UnitOfMeasureType/Edit/5
        public async Task <ActionResult> Edit(Guid id)
        {
            var unitOfMeasureType = new EditUnitOfMeasureTypeViewModel();

            try
            {
                var result = await _unitOfMeasureTypeService.FindById(id);

                if (!result.Success)
                {
                    Alert($"Error! {result.Message}", NotificationType.info, Int32.Parse(_appConfig.Value.NotificationDisplayTime));
                    return(View(unitOfMeasureType));
                }
                unitOfMeasureType.Id          = result.Data.Id;
                unitOfMeasureType.Name        = result.Data.Name;
                unitOfMeasureType.Description = result.Data.Description;
                return(View(unitOfMeasureType));
            }
            catch (Exception ex)
            {
                Alert($"Error! {ex.Message}", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime));
                return(View(unitOfMeasureType));
            }
        }