Пример #1
0
        /// <summary>
        /// Save Style
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public ResponseModel SaveStyleManageModel(StyleManageModel model)
        {
            ResponseModel response;
            var           style = GetById(model.Id);

            if (style != null)
            {
                var log = new StyleLogManageModel(style);
                style.Name              = model.Name;
                style.Content           = model.Content;
                style.CdnUrl            = model.CdnUrl;
                style.IncludeIntoEditor = model.IncludeIntoEditor;

                response = Update(style);
                if (response.Success)
                {
                    _styleLogService.SaveStyleLog(log);
                }
                return(response.SetMessage(response.Success
                    ? T("Style_Message_UpdateSuccessfully")
                    : T("Style_Message_UpdateFailure")));
            }

            Mapper.CreateMap <StyleManageModel, Style>();
            style    = Mapper.Map <StyleManageModel, Style>(model);
            response = Insert(style);
            return(response.SetMessage(response.Success
                ? T("Style_Message_CreateSuccessfully")
                : T("Style_Message_CreateFailure")));
        }
Пример #2
0
        public ActionResult Edit(int?id, int?logId)
        {
            StyleManageModel model = null;

            if (id.HasValue)
            {
                model = _styleService.GetStyleManageModel(id.Value);
            }
            else if (logId.HasValue)
            {
                model = _styleService.GetStyleManageModelByLogId(logId.Value);
            }
            if (model == null)
            {
                SetErrorMessage(T("Style_Message_ObjectNotFound"));
                return(RedirectToAction("Index"));
            }
            return(View(model));
        }
Пример #3
0
        public ActionResult Edit(StyleManageModel model, SubmitType submit)
        {
            if (ModelState.IsValid)
            {
                var response = _styleService.SaveStyleManageModel(model);
                SetResponseMessage(response);
                if (response.Success)
                {
                    switch (submit)
                    {
                    case SubmitType.Save:
                        return(RedirectToAction("Index"));

                    default:
                        return(RedirectToAction("Edit", new { id = model.Id }));
                    }
                }
            }
            return(View(model));
        }