Пример #1
0
 public ActionResult Edit(Models.TestimonialModel data)
 {
     try
     {
         if (ModelState.IsValid)
         {
             CLayer.Testimonial testimonial = new CLayer.Testimonial()
             {
                 TestimonialId = data.TestimonialId,
                 Name          = data.Name,
                 Company       = data.Company,
                 Picture       = data.Picture,
                 Title         = data.Title,
                 Description   = data.Description,
                 Status        = data.Status,
                 ShowInWidget  = data.ShowInWidget
             };
             //Picture saving
             //if (data.photo != null && data.photo.ContentLength > 0)
             //{
             //    int MaxContentLength = 1024 * 1024 * 3; //3 MB
             //    string[] AllowedFileExtensions = new string[] { ".jpg", ".gif", ".png", ".pdf" };
             //    if (!AllowedFileExtensions.Contains(data.photo.FileName.Substring(data.photo.FileName.LastIndexOf('.'))))
             //    {
             //        ModelState.AddModelError(string.Empty, "Please file of type: " + string.Join(", ", AllowedFileExtensions));
             //    }
             //    else if (data.photo.ContentLength > MaxContentLength)
             //    {
             //        ModelState.AddModelError(string.Empty, "Your file is too large, maximum allowed size is: " + MaxContentLength + " MB");
             //    }
             //    else
             //    {
             //        var fileName = System.IO.Path.GetFileName(data.photo.FileName);
             //        var path = System.IO.Path.Combine(Server.MapPath("~/Files/Testimonials"), fileName);
             //        data.photo.SaveAs(path);
             //        testimonial.Picture = fileName;
             //        ModelState.Clear();
             //    }
             //}
             BLayer.Testimonial.Save(testimonial);
         }
         if (data.Status == 1)
         {
             return(RedirectToAction("Index"));
         }
         else
         {
             return(RedirectToAction("Inactive"));
         }
     }
     catch (Exception ex)
     {
         ViewBag.Message = ex.Message;
         return(View("Edit", data));
     }
 }
Пример #2
0
        public ActionResult SendTestimonialToTutor(Models.TestimonialModel model)
        {
            try
            {
                var res = BLL.Data.StudentData.SendTestimonial(new BLL.DTO.TestimonialDTO
                {
                    requestId = model.requestId,
                    text      = model.text,
                    star      = model.star,
                    date      = DateTime.Now
                });
            }
            catch (Exception ex)
            {
                ViewBag.Message = ex.Message;
            }

            return(Json(new { success = true }));
        }