Exemplo n.º 1
0
        public ActionResult Edit(RotatingImageGroupManageModel model, SubmitType submit)
        {
            if (ModelState.IsValid)
            {
                var response = _rotatingImageGroupService.SaveRotatingImageGroup(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));
        }
        /// <summary>
        /// Save RotatingImageGroup
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public ResponseModel SaveRotatingImageGroup(RotatingImageGroupManageModel model)
        {
            ResponseModel response;
            var           rotatingImageGroup = GetById(model.Id);

            if (rotatingImageGroup != null)
            {
                rotatingImageGroup.Name = model.Name;
                response = Update(rotatingImageGroup);
                return(response.SetMessage(response.Success
                    ? T("RotatingImageGroup_Message_UpdateSuccessfully")
                    : T("RotatingImageGroup_Message_UpdateFailure")));
            }
            Mapper.CreateMap <RotatingImageGroupManageModel, RotatingImageGroup>();
            rotatingImageGroup = Mapper.Map <RotatingImageGroupManageModel, RotatingImageGroup>(model);
            response           = Insert(rotatingImageGroup);
            return(response.SetMessage(response.Success
                ? T("RotatingImageGroup_Message_CreateSuccessfully")
                : T("RotatingImageGroup_Message_CreateFailure")));
        }