コード例 #1
0
        public ActionResult Edit(ActiveComponentViewModel model) {
            try{
                var svc = new ActiveComponentAppService();
                var o = new ActiveComponent{
                    ActiveComponentId = model.ActiveComponentId,
                    Name = model.Name
                };
                if (model.Action == "-1"){
                    var exist = svc.GetActiveComponent(model.ActiveComponentId) != null;
                    if (!exist){
                        svc.AddActiveComponent(o);
                        this.ViewBag.Feed = 0;
                    } else{
                        model.Action = "-1";
                        this.ViewBag.Feed = 3;
                        return this.View(model);
                    }
                } else{
                    o.ActiveComponentId = model.ActiveComponentId;
                    if (model.IsDeleteAction == 0) svc.SaveActiveComponent(o);
                    else svc.RemoveActiveComponent(model.ActiveComponentId);
                    this.ViewBag.Feed = 0;
                }
            } catch (Exception){
                this.ViewBag.Feed = 1;
            }

            return this.View(model);
        }
コード例 #2
0
        /// <summary>
        ///     Edits the specified identifier.
        /// </summary>
        /// <param name="id">The identifier.</param>
        /// <returns>ActionResult.</returns>
        public ActionResult Edit(int id) {
            var model = new ActiveComponentViewModel();

            if (id != -1){
                var svc = new ActiveComponentAppService();
                var o = svc.GetActiveComponent(id);
                model.ActiveComponentId = o.ActiveComponentId;
                model.Name = o.Name;
            } else{
                model.Action = "-1";
                model.ActiveComponentId = -1;
                model.Name = string.Empty;
            }

            return this.View(model);
        }