public IActionResult AddTestimonial(AddUpdateTestimonialModel addTestimonial)
 {
     try
     {
         if (ModelState.IsValid)
         {
             var testimonialModel = TestimonialHelper.BindTestimonialModel(addTestimonial);
             if (testimonialModel.TestimonialId <= 0)
             {
                 long testimonialId = iTestimonial.AddTestimonial(testimonialModel);
                 if (testimonialId > 0)
                 {
                     return(Ok(ResponseHelper.Success(MessageConstants.TestimonialAdded)));
                 }
                 else
                 {
                     return(Ok(ResponseHelper.Error(MessageConstants.TestimonialNotAdded)));
                 }
             }
             else
             {
                 long testimonialId = iTestimonial.UpdateTestimonial(testimonialModel);
                 if (testimonialId > 0)
                 {
                     return(Ok(ResponseHelper.Success(MessageConstants.TestimonialUpdated)));
                 }
                 else
                 {
                     return(Ok(ResponseHelper.Error(MessageConstants.TestimonialNotUpdated)));
                 }
             }
         }
         else
         {
             return(Ok(ResponseHelper.Error(MessageConstants.CompulsoryData)));
         }
     }
     catch (Exception ex)
     {
         LogHelper.ExceptionLog(ex.Message + "  :::::  " + ex.StackTrace);
         return(Ok(ResponseHelper.Error(ex.Message)));
     }
 }
Example #2
0
        /// <summary>
        /// Binds the testimonial model.
        /// </summary>
        /// <param name="addTestimonial">The add testimonial.</param>
        /// <returns></returns>
        public static Testimonials BindTestimonialModel(AddUpdateTestimonialModel addTestimonial)
        {
            Testimonials testimonialModel = new Testimonials();

            if (addTestimonial != null)
            {
                if (addTestimonial.TestimonialId <= 0)
                {
                    testimonialModel.CreatedOn = DateTime.Now;
                    testimonialModel.UserFK    = addTestimonial.UserId;
                }
                else
                {
                    testimonialModel.ModifiedOn    = DateTime.Now;
                    testimonialModel.TestimonialId = addTestimonial.TestimonialId;
                }
                testimonialModel.Message = addTestimonial.Message;
            }
            return(testimonialModel);
        }