Exemplo n.º 1
0
        public JsonResult Manage(RotatingImageModel model, GridManagingModel manageModel)
        {
            if (ModelState.IsValid || manageModel.Operation == GridOperationEnums.Del)
            {
                return(Json(_rotatingImageServices.ManageRotatingImage(manageModel.Operation, model)));
            }

            return(Json(new ResponseModel
            {
                Success = false,
                Message = GetFirstValidationResults(ModelState).Message
            }));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Manage Rotating Images
        /// </summary>
        /// <param name="operation">the operation</param>
        /// <param name="model">the setting model</param>
        /// <returns></returns>
        public ResponseModel ManageRotatingImage(GridOperationEnums operation, RotatingImageModel model)
        {
            ResponseModel response;

            Mapper.CreateMap <RotatingImageModel, RotatingImage>();
            RotatingImage rotatingImage;

            switch (operation)
            {
            case GridOperationEnums.Edit:
                rotatingImage             = GetById(model.Id);
                rotatingImage.ImageUrl    = model.ImageUrl;
                rotatingImage.Url         = model.Url;
                rotatingImage.GroupId     = model.GroupName.ToInt();
                rotatingImage.RecordOrder = model.RecordOrder;
                response = Update(rotatingImage);
                return(response.SetMessage(response.Success ?
                                           _localizedResourceServices.T("AdminModule:::RotatingImages:::Messages:::UpdateSuccessfully:::Update rotating image successfully.")
                        : _localizedResourceServices.T("AdminModule:::RotatingImages:::Messages:::UpdateFailure:::Update rotating image failed. Please try again later.")));

            case GridOperationEnums.Add:
                rotatingImage          = Mapper.Map <RotatingImageModel, RotatingImage>(model);
                rotatingImage.ImageUrl = string.Empty;
                rotatingImage.GroupId  = model.GroupName.ToInt();

                response = Insert(rotatingImage);
                return(response.SetMessage(response.Success ?
                                           _localizedResourceServices.T("AdminModule:::RotatingImages:::Messages:::CreateSuccessfully:::Create rotating image successfully.")
                        : _localizedResourceServices.T("AdminModule:::RotatingImages:::Messages:::CreateFailure:::Insert rotating image failed. Please try again later.")));

            case GridOperationEnums.Del:
                response = Delete(model.Id);
                return(response.SetMessage(response.Success ?
                                           _localizedResourceServices.T("AdminModule:::RotatingImages:::Messages:::DeleteSuccessfully:::Delete rotating image successfully.")
                        : _localizedResourceServices.T("AdminModule:::RotatingImages:::Messages:::DeleteFailure:::Delete rotating image failed. Please try again later.")));
            }
            return(new ResponseModel
            {
                Success = false,
                Message = _localizedResourceServices.T("AdminModule:::RotatingImages:::Messages:::ObjectNotFounded:::Rotating image is not founded.")
            });
        }