コード例 #1
0
        public async Task <IActionResult> Edit(int id, LabelFormModel model)
        {
            var labelExists = await this.labelService.ExistsAsync(id);

            if (!labelExists)
            {
                this.TempData.AddErrorMessage(WebAdminConstants.LabelNotFoundMsg);
                return(RedirectToAction(nameof(Index)));
            }

            if (!this.ModelState.IsValid)
            {
                return(this.View(model));
            }

            await this.labelService.UpdateAsync(
                id,
                model.Name,
                model.Description);

            this.TempData.AddSuccessMessage(string.Format(
                                                WebAdminConstants.LabelUpdatedMsg,
                                                model.Name.ToStrongHtml()));

            return(this.RedirectToAction(nameof(Index)));
        }
コード例 #2
0
        public ActionResult Add(int sourceType, int sourceId, LabelFormModel model)
        {
            var label = LabelService.LabelAdd((SourceType)sourceType, sourceId, model.Name);

            if (label.IsValid)
            {
                model.IsNew = true;
            }

            this.Map(label, model, false);

            return(PartialView("LabelUserControl", model));
        }
コード例 #3
0
        public ActionResult Add(int sourceType, int sourceId, LabelFormModel model)
        {
            var label = LabelService.LabelAdd((SourceType)sourceType, sourceId, model.Name);

            if (label.IsValid)
            {
                model.IsNew = true;
            }

            this.Map(label, model, false);

            return PartialView("LabelUserControl", model);
        }
コード例 #4
0
        public async Task <IActionResult> Create(LabelFormModel model)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.View(model));
            }

            await this.labelService.CreateAsync(
                model.Name,
                model.Description);

            this.TempData.AddSuccessMessage(string.Format(
                                                WebAdminConstants.LabelCreatedMsg,
                                                model.Name.ToStrongHtml()));

            return(this.RedirectToAction(nameof(Index)));
        }
コード例 #5
0
        public LabelFormModel Map(Label label, LabelFormModel model, bool ignoreBrokenRules)
        {
            Csla.Data.DataMapper.Map(label, model, true);

            model.Tab     = "Task";
            model.IsNew   = label.IsNew;
            model.IsValid = label.IsValid;

            if (!ignoreBrokenRules)
            {
                foreach (var brokenRule in label.BrokenRulesCollection)
                {
                    this.ModelState.AddModelError(string.Empty, brokenRule.Description);
                }
            }

            return(model);
        }
コード例 #6
0
        public LabelFormModel Map(Label label, LabelFormModel model, bool ignoreBrokenRules)
        {
            Csla.Data.DataMapper.Map(label, model, true);

            model.Tab = "Task";
            model.IsNew = label.IsNew;
            model.IsValid = label.IsValid;

            if (!ignoreBrokenRules)
            {
                foreach (var brokenRule in label.BrokenRulesCollection)
                {
                    this.ModelState.AddModelError(string.Empty, brokenRule.Description);
                }
            }

            return model;
        }