Example #1
0
        public async Task <IActionResult> MetricAddPost(MetricWorkModel model)
        {
            Task select = GetMetricSelects(model);

            model.DropDeletedColumns();

            if (ModelState.IsValid)
            {
                var result = await _crudService.Create(model.TranslateToMetricModel(), Token, SettingService.MetricEntity);

                AddMessageToModel(model, result.Message, !result.Success);

                if (result.Success)
                {
                    return(RedirectToActionWithId(model, "MetricEdit", "Setting", result.Id));
                }
            }
            else
            {
                AddModelStateErrors(model);
            }

            Task.WaitAll(select);

            return(View("Metric/Add", model));
        }
Example #2
0
        public async Task <IActionResult> MetricEditPost(int id, MetricWorkModel model)
        {
            Task select = GetMetricSelects(model);

            model.DropDeletedColumns();

            if (ModelState.IsValid)
            {
                var result = await _crudService.Edit(id, model.TranslateToMetricModel(), Token, SettingService.MetricEntity);

                AddMessageToModel(model, result.Message, !result.Success);
            }
            else
            {
                AddModelStateErrors(model);
            }

            Task.WaitAll(select);

            return(View("Metric/Edit", model));
        }