Ejemplo n.º 1
0
        public JsonResult Manage(TestimonialModel model, GridManagingModel manageModel)
        {
            if (ModelState.IsValid || manageModel.Operation == GridOperationEnums.Del)
            {
                return Json(_testimonialServices.ManageTestimonial(manageModel.Operation, model));
            }

            return Json(new ResponseModel
            {
                Success = false,
                Message = GetFirstValidationResults(ModelState).Message
            });
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Manage testimonial
        /// </summary>
        /// <param name="operation">the operation</param>
        /// <param name="model">the testimonial model</param>
        /// <returns></returns>
        public ResponseModel ManageTestimonial(GridOperationEnums operation, TestimonialModel model)
        {
            ResponseModel response;
            Mapper.CreateMap<TestimonialModel, Testimonial>();
            Testimonial testimonial;
            switch (operation)
            {
                case GridOperationEnums.Edit:
                    testimonial = _testimonialRepository.GetById(model.Id);
                    testimonial.Author = model.Author;
                    testimonial.Content = model.Content;
                    testimonial.AuthorDescription = model.AuthorDescription;
                    testimonial.RecordOrder = model.RecordOrder;
                    testimonial.RecordActive = model.RecordActive;
                    response = Update(testimonial);
                    return response.SetMessage(response.Success ?
                        _localizedResourceServices.T("AdminModule:::Testimonials:::Messages:::UpdateSuccessfully:::Update testimonial successfully.")
                        : _localizedResourceServices.T("AdminModule:::Testimonials:::Messages:::UpdateFailure:::Update testimonial failed. Please try again later."));

                case GridOperationEnums.Add:
                    testimonial = Mapper.Map<TestimonialModel, Testimonial>(model);
                    response = Insert(testimonial);
                    return response.SetMessage(response.Success ?
                        _localizedResourceServices.T("AdminModule:::Testimonials:::Messages:::CreateSuccessfully:::Create testimonial successfully.")
                        : _localizedResourceServices.T("AdminModule:::Testimonials:::Messages:::CreateFailure:::Insert testimonial failed. Please try again later."));

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