Esempio n. 1
0
        /// <summary>
        /// Get rotating image manage model for edit/create
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public RotatingImageManageModel GetRotatingImageManageModel(int?id = null)
        {
            var rotatingImage = GetById(id);

            if (rotatingImage != null)
            {
                return(new RotatingImageManageModel
                {
                    Id = rotatingImage.Id,
                    ImageUrl = rotatingImage.ImageUrl,
                    Text = rotatingImage.Text,
                    Url = rotatingImage.Url,
                    GroupId = rotatingImage.GroupId,
                    Groups = _rotatingImageGroupServices.GetRotatingImageGroups()
                });
            }
            return(new RotatingImageManageModel
            {
                Groups = _rotatingImageGroupServices.GetRotatingImageGroups()
            });
        }
Esempio n. 2
0
        public ActionResult Create(RotatingImageManageModel model, SubmitTypeEnums submit)
        {
            if (ModelState.IsValid)
            {
                var response = _rotatingImageServices.SaveRotatingImage(model);
                if (response.Success)
                {
                    var rotatingImageId = (int)response.Data;
                    SetSuccessMessage(response.Message);
                    switch (submit)
                    {
                    case SubmitTypeEnums.Save:
                        return(RedirectToAction("Index"));

                    default:
                        return(RedirectToAction("Edit", new { id = rotatingImageId }));
                    }
                }
                SetErrorMessage(response.Message);
            }
            model.Groups = _rotatingImageGroupServices.GetRotatingImageGroups();
            return(View(model));
        }
 public JsonResult GetGroups()
 {
     return(Json(_rotatingImageGroupServices.GetRotatingImageGroups(), JsonRequestBehavior.AllowGet));
 }