Пример #1
0
 private void TestimonialBind()
 {
     try
     {
         ds = objInteraction.TestimonialSelectAll();
         if (ds.Tables.Count > 0)
         {
             if (ds.Tables[0].Rows.Count > 0)
             {
                 Testimonial.DataSource = ds.Tables[0];
                 Testimonial.DataBind();
             }
             else
             {
                 Testimonial.DataSource = null;
                 Testimonial.DataBind();
             }
         }
         else
         {
             Testimonial.DataSource = null;
             Testimonial.DataBind();
         }
     }
     catch (Exception ex)
     {
     }
 }
Пример #2
0
        /// <summary>
        /// Cleanses the testimonial.
        /// </summary>
        /// <param name="postedTestimonial">The posted testimonial.</param>
        public void CleanseTestimonial(ref Testimonial postedTestimonial)
        {
            //// Format Name
            var textInfo = new CultureInfo("en-US", false).TextInfo;

            postedTestimonial.AuthorFirstName = textInfo.ToTitleCase(postedTestimonial.AuthorFirstName.Trim());
            postedTestimonial.AuthorLastName  = textInfo.ToTitleCase(postedTestimonial.AuthorLastName.Trim());

            //// Format Job
            postedTestimonial.AuthorDesignation  = string.IsNullOrWhiteSpace(postedTestimonial.AuthorDesignation) ? string.Empty : Regex.Replace(postedTestimonial.AuthorDesignation.Trim(), @"\s+", " ");
            postedTestimonial.AuthorOrganization = Regex.Replace(postedTestimonial.AuthorOrganization.Trim(), @"\s+", " ");
            postedTestimonial.AuthorDesignation  = textInfo.ToTitleCase(postedTestimonial.AuthorDesignation.Trim());
            postedTestimonial.AuthorOrganization = textInfo.ToTitleCase(postedTestimonial.AuthorOrganization.Trim());

            postedTestimonial.AuthorEmail = postedTestimonial.AuthorEmail.ToLowerInvariant().Trim();
            postedTestimonial.AuthorToken = postedTestimonial.AuthorToken.ToLowerInvariant().Trim();

            //// Remove multiple line breaks from comments. Multiple spaces. Make first character capital. Fix punctuation.
            postedTestimonial.AuthorComments = Regex.Replace(postedTestimonial.AuthorComments, @"(?:\r\n|\r(?!\n)|(?<!\r)\n){2,}", "<br />");
            postedTestimonial.AuthorComments = Regex.Replace(postedTestimonial.AuthorComments.Trim(), @"\s+", " ");
            if (!string.IsNullOrWhiteSpace(postedTestimonial.AuthorComments))
            {
                postedTestimonial.AuthorComments = postedTestimonial.AuthorComments.First().ToString(CultureInfo.InvariantCulture).ToUpper() + postedTestimonial.AuthorComments.Substring(1);
                var comments = postedTestimonial.AuthorComments.ToCharArray();
                foreach (Match match in Regex.Matches(postedTestimonial.AuthorComments, @"[\.\?\!,]\s+([a-z])", RegexOptions.Singleline))
                {
                    comments[match.Groups[1].Index] = char.ToUpper(comments[match.Groups[1].Index]);
                }

                postedTestimonial.AuthorComments = new string(comments);
            }
        }
Пример #3
0
        public ActionResult EditTestimonial(Testimonial testimonial, HttpPostedFileBase image)
        {
            if (ModelState.IsValid)
            {
                if (image == null)
                {
                    testimonialrepository.SaveSimpleTestimonial(testimonial);
                    TempData["message"] = string.Format("{0} has been saved", testimonial.TestimonialUser);
                }
                else
                {
                    testimonial.TestimonialMimeType  = image.ContentType;
                    testimonial.TestimonialImageData = new byte[image.ContentLength];
                    image.InputStream.Read(testimonial.TestimonialImageData, 0, image.ContentLength);

                    testimonialrepository.SaveTestimonial(testimonial);
                    TempData["message"] = string.Format("{0} has been saved", testimonial.TestimonialUser);
                }
                return(RedirectToAction("Testimonial"));
            }
            else
            {
                return(View(testimonial));
            }
        }
        public void update(TestimonialDto testimonial_dto)
        {
            try
            {
                _transactionManager.beginTransaction();


                Testimonial testimonial = _testimonialRepo.getById(testimonial_dto.testimonial_id);

                string oldImage = testimonial.image_name;

                _testimonialMaker.copy(ref testimonial, testimonial_dto);

                _testimonialRepo.update(testimonial);

                if (!string.IsNullOrWhiteSpace(testimonial_dto.image_name))
                {
                    if (!string.IsNullOrWhiteSpace(oldImage))
                    {
                        deleteImage(oldImage);
                    }
                }
                _transactionManager.commitTransaction();
            }
            catch (Exception)
            {
                _transactionManager.rollbackTransaction();
                throw;
            }
        }
Пример #5
0
        public async Task <ServiceResponse <Testimonial> > EditAsync(Testimonial entity)
        {
            if (IsExists(entity))
            {
                return(new ServiceResponse <Testimonial>(false, new List <Messages> {
                    AppMessages.DataAlreadyExist
                }));
            }
            try
            {
                entity.ModifiedBy   = _webHelper.CurrentUser;
                entity.ModifiedDate = _webHelper.CurrentDateUtc;
                entity.IpAddress    = _webHelper.GetCurrentIpAddress();
                _repository.Update(entity);
                await _unitOfWork.CommitAsync();

                return(new ServiceResponse <Testimonial>(true)
                {
                    Messages = new List <Messages> {
                        AppMessages.DataupdatedSuccessfully
                    }
                });
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.ToExceptionMessage()?.Message);
                return(new ServiceResponse <Testimonial>(false, new List <Messages> {
                    AppMessages.TechincalProblemOccured
                }, MessageType.Danger));
            }
        }
        public async Task <IActionResult> Add(List <string> Texts, string Name)
        {
            if (Texts != null && Name != null)
            {
                Testimonial testimonial = new Testimonial();
                testimonial.Name = Name;
                await _context.Testimonials.AddAsync(testimonial);

                List <Language> languages = await _context.Languages.ToListAsync();

                for (int i = 0; i < languages.Count; i++)
                {
                    if (Texts[i] != null)
                    {
                        TestimonialLanguage testimonialLanguage = new TestimonialLanguage()
                        {
                            TestimonialId = testimonial.Id,
                            Text          = Texts[i],
                            LanguageId    = languages[i].Id
                        };
                        await _context.TestimonialLanguages.AddAsync(testimonialLanguage);
                    }
                }

                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }

            return(RedirectToAction(nameof(Add)));
        }
Пример #7
0
        public ActionResult Edit(Testimonial testimonial, HttpPostedFileBase TestimonialImage)
        {
            if (ModelState.IsValid)
            {
                #region Upload Image
                if (TestimonialImage != null)
                {
                    if (System.IO.File.Exists(Server.MapPath("/Files/TestimonialImages/" + testimonial.Image)))
                    {
                        System.IO.File.Delete(Server.MapPath("/Files/TestimonialImages/" + testimonial.Image));
                    }

                    // Saving Temp Image
                    var newFileName = Guid.NewGuid() + Path.GetExtension(TestimonialImage.FileName);
                    TestimonialImage.SaveAs(Server.MapPath("/Files/TestimonialImages/Temp/" + newFileName));
                    // Resize Image
                    ImageResizer image = new ImageResizer(400, 400);
                    image.Resize(Server.MapPath("/Files/TestimonialImages/Temp/" + newFileName),
                                 Server.MapPath("/Files/TestimonialImages/" + newFileName));

                    // Deleting Temp Image
                    System.IO.File.Delete(Server.MapPath("/Files/TestimonialImages/Temp/" + newFileName));
                    testimonial.Image = newFileName;
                }
                #endregion
                _repo.Update(testimonial);
                return(RedirectToAction("Index"));
            }
            return(View(testimonial));
        }
Пример #8
0
        public ActionResult Edit(Testimonial newTestimonial)
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToAction("Index", "SiteAdmin"));
            }

            try
            {
                _repository.Edit(newTestimonial);
                return(RedirectToAction("Index", "SiteAdmin", new { area = "" }));
            }
            catch (ApplicationException ex)
            {
                if (ex.Message == DbError.UpdateFailed.ToString())
                {
                    return(RedirectToAction("Edit"));
                }
                if (ex.Message == DbError.ConcurrencyError.ToString())
                {
                    return(RedirectToAction("Index", "SiteAdmin"));
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }

            return(RedirectToAction("Index", "SiteAdmin"));
        }
Пример #9
0
        public IHttpActionResult PutTestimonial(int id, Testimonial testimonial)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != testimonial.ID)
            {
                return(BadRequest());
            }

            db.Entry(testimonial).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TestimonialExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Пример #10
0
 public Testimonial CreateTestimonial(Testimonial model)
 {
     model.AddedDate = DateTime.Now;
     _context.Testimonials.Add(model);
     _context.SaveChanges();
     return(model);
 }
        public ActionResult Add(string first_name = "", string last_name = "", string location = "", string testimonial = "")
        {
            Testimonial t = new Testimonial {
                testimonial1 = testimonial,
                first_name = (first_name.Trim() == "") ? null : first_name.Trim(),
                last_name = (last_name.Trim() == "") ? null : last_name.Trim(),
                location = (location.Trim() == "") ? null : location.Trim()
            };
            string message = "";
            try {
                string remoteip = (Request.ServerVariables["HTTP_X_FORWARDED_FOR"] != null) ? Request.ServerVariables["HTTP_X_FORWARDED_FOR"] : Request.ServerVariables["REMOTE_ADDR"];
                bool recaptchavalid = ReCaptcha.ValidateCaptcha(Request.Form["recaptcha_challenge_field"], Request.Form["recaptcha_response_field"], remoteip);
                if (!recaptchavalid) message += "Captcha was incorrect. ";
                if (testimonial.Trim() == "") message += "A Testimonial is required.";

                if (message.Length > 0) throw new Exception(message);
                t = TestimonialModel.Add(first_name, last_name, location, testimonial);
                return RedirectToAction("Add", "Testimonials", new { message = "Thanks for submitting a Testimonial!" });

            } catch (Exception e) {
                message = e.Message;
                TempData["testimonial"] = t;
            }
            return RedirectToAction("Add", "Testimonials", new { message = message });
        }
        //
        // GET: /Admin/Testimonial/Edit/5

        public ActionResult Edit(int id)
        {
            Testimonial testimonial = db.Testimonial.Find(id);

            ViewBag.MediaExtensionId = new SelectList(db.MediaExtension, "MediaExtensionId", "MediaExtensionName", testimonial.MediaExtensionId);
            return(View(testimonial));
        }
Пример #13
0
    protected void CreateTestimonialButton_Click(object sender, EventArgs e)
    {
        try
        {
            ErrorMessagePanel.Visible = SuccMessagePanel.Visible = false;

            if (!Member.IsLogged)
            {
                AccessManager.RedirectIfDisabled(false);
            }

            string body      = InputChecker.HtmlEncode(BodyTextBox.Text, BodyTextBox.MaxLength, L1.TEXT);
            string signature = InputChecker.HtmlEncode(SignatureTextBox.Text, SignatureTextBox.MaxLength, U5008.SIGNATURE);

            Testimonial.Add(Member.CurrentId, body, signature);
            ClearAll();
            SuccMessagePanel.Visible = true;
            SuccMessage.Text         = U5008.THANKSFORFEEDBACK;
        }
        catch (Exception ex)
        {
            if (ex is MsgException)
            {
                ErrorMessagePanel.Visible = true;
                ErrorMessage.Text         = ex.Message;
            }
            else
            {
                ErrorLogger.Log(ex);
            }
        }
    }
        public static long InsertTestimonial(Testimonial testimonial)
        {
            SqlTestimonialProvider sqlTestimonialProvider = new SqlTestimonialProvider();
            var id = sqlTestimonialProvider.InsertTestimonial(testimonial);

            return(id);
        }
        public static bool UpdateTestimonial(Testimonial testimonial)
        {
            SqlTestimonialProvider sqlTestimonialProvider = new SqlTestimonialProvider();
            var isUpdate = sqlTestimonialProvider.UpdateTestimonial(testimonial);

            return(isUpdate);
        }
Пример #16
0
        public Boolean AddTestimonial(Testimonial comment)
        {
            if (comment != null)
            {
                DBConnect  objDB      = new DBConnect();
                SqlCommand addTestcmd = new SqlCommand();

                addTestcmd.CommandType = CommandType.StoredProcedure;
                addTestcmd.CommandText = "TP_AddTestimonial";

                addTestcmd.Parameters.AddWithValue("@artist_ID", comment.artist_ID);
                addTestcmd.Parameters.AddWithValue("@cust_ID", comment.cust_ID);
                addTestcmd.Parameters.AddWithValue("@title", comment.title);
                addTestcmd.Parameters.AddWithValue("@body", comment.body);

                int result = objDB.DoUpdateUsingCmdObj(addTestcmd);

                if (result > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
Пример #17
0
        public ActionResult AddTestimonial(string first_name = "", string last_name = "", string location = "", double rating = 0, string addtitle = "", string testimonial = "")
        {
            Testimonial t = new Testimonial();
            List<string> errors = new List<string>();
            try {
                string remoteip = (Request.ServerVariables["HTTP_X_FORWARDED_FOR"] != null) ? Request.ServerVariables["HTTP_X_FORWARDED_FOR"] : Request.ServerVariables["REMOTE_ADDR"];
                bool recaptchavalid = ReCaptcha.ValidateCaptcha(Request.Form["recaptcha_challenge_field"], Request.Form["recaptcha_response_field"], remoteip);
                if (!recaptchavalid) errors.Add("Captcha was incorrect.");
                if (rating == 0) errors.Add("Rating is required.");
                if (addtitle.Trim() == "") errors.Add("A Title is required.");
                if (testimonial.Trim() == "") errors.Add("A Testimonial is required.");
                if (errors.Count() > 0) throw new Exception();

                t = TestimonialModel.Add(first_name, last_name, location, addtitle, testimonial, rating);

                string message = "Your Testimonial has been submitted successfully. Thank you!";
                return RedirectToAction("Index", "Testimonials", new { message = message });
            } catch {
                TempData["first_name"] = first_name;
                TempData["last_name"] = last_name;
                TempData["location"] = location;
                TempData["addtitle"] = addtitle;
                TempData["testimonial"] = testimonial;
                TempData["rating"] = rating;
                return RedirectToAction("Index", "Testimonials");
            }
        }
Пример #18
0
        public async Task <ActionResult> Create([Bind(Include = "TestimonialId,Label,Date,ImageUrl")] Testimonial testimonial)
        {
            // Check file is exists and is valid image
            HttpPostedFileBase imageFile = _ModelControllersHelper.GetImageFile(ModelState, Request, "");

            if (ModelState.IsValid)
            {
                // Save image to disk and store filepath in model
                try
                {
                    string timeStamp = FileManager.GetTimeStamp();
                    testimonial.ImageUrl = await imageSaver.SaveFile(imageFile, 200, timeStamp);

                    testimonial.ImageSrcSet = await imageSaver.SaveImageMultipleSizes(imageFile, new List <int>() { 1600, 800, 400, 200 }, timeStamp);
                }
                catch
                {
                    ModelState.AddModelError("ImageUrl", "Failure saving image. Please try again.");
                    return(View(testimonial));
                }

                // add new model
                db.Testimonials.Add(testimonial);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(testimonial));
        }
Пример #19
0
        public async Task <IActionResult> Edit(int?id, Testimonial testimonial, IFormFile File)
        {
            if (id == null)
            {
                return(NotFound());
            }
            Testimonial newTestimonial = await _db.Testimonials.FindAsync(id);

            if (newTestimonial == null)
            {
                return(NotFound());
            }
            if (File != null)
            {
                if (!File.isImage())
                {
                    ModelState.AddModelError(string.Empty, "Please pick a file matching the format!");
                    return(View());
                }
                Extensions.DeleteImg(_env.WebRootPath, "img/testimonial", newTestimonial.Image);
                newTestimonial.Image = await File.SaveImg(_env.WebRootPath, "img/testimonial");
            }
            newTestimonial.Fullname      = testimonial.Fullname;
            newTestimonial.Review        = testimonial.Review;
            newTestimonial.Duty          = testimonial.Duty;
            newTestimonial.Qualification = testimonial.Qualification;
            await _db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Пример #20
0
        private static Testimonial MapTestimonial(IDataReader reader)
        {
            Testimonial p  = new Testimonial();
            PersonBase  pb = new PersonBase();

            p.Person = pb;

            int ord = 0; //startingOrdinal

            p.Id           = reader.GetSafeInt32(ord++);
            p.Content      = reader.GetSafeString(ord++);
            p.DateCreated  = reader.GetSafeDateTime(ord++);
            p.DateModified = reader.GetSafeDateTime(ord++);
            pb.Id          = reader.GetSafeInt32(ord++);
            pb.FirstName   = reader.GetSafeString(ord++);
            pb.MiddleName  = reader.GetSafeString(ord++);
            pb.LastName    = reader.GetSafeString(ord++);
            pb.PhoneNumber = reader.GetSafeString(ord++);
            pb.Email       = reader.GetSafeString(ord++);
            pb.JobTitle    = reader.GetSafeString(ord++);
            string photo = reader.GetSafeString(ord++);

            pb.ProfilePicture = "https://sabio-training.s3-us-west-2.amazonaws.com/C31/" + photo;
            p.Inactive        = reader.GetSafeBool(ord++);
            return(p);
        }
Пример #21
0
        public List <Testimonial> GetAllTestimonials(int artist_ID)
        {
            DBConnect  objDB      = new DBConnect();
            SqlCommand objCommand = new SqlCommand();

            objCommand.CommandType = CommandType.StoredProcedure;
            objCommand.CommandText = "TP_GetAllTestimonials";

            List <Testimonial> TestimonialList = new List <Testimonial>();

            SqlParameter artistID = new SqlParameter("@artist_ID", artist_ID);

            artistID.Direction = ParameterDirection.Input;
            objCommand.Parameters.Add(artistID);

            DataSet testimonials = objDB.GetDataSetUsingCmdObj(objCommand);

            foreach (DataRow record in testimonials.Tables[0].Rows)
            {
                Testimonial comment = new Testimonial();
                comment.artist_ID = Int32.Parse(record["Artist_ID"].ToString());
                comment.title     = record["Title"].ToString();
                comment.body      = record["Body"].ToString();

                TestimonialList.Add(comment);
            }
            return(TestimonialList);
        }
Пример #22
0
        public List <Testimonial> SelectAll()
        {
            List <Testimonial> list = null;

            DataProvider.ExecuteCmd(GetConnection, "dbo.Testimonial_SelectAll"
                                    , inputParamMapper : null
                                    , map : delegate(IDataReader reader, short set)
            {
                switch (set)
                {
                case 0:
                    Testimonial p = MapTestimonial(reader);
                    if (list == null)
                    {
                        list = new List <Testimonial>();
                    }
                    list.Add(p);
                    break;
                }
            }
                                    );


            return(list);
        }
        public JsonResult UpdateActive(int?id)
        {
            var result = false;

            if (id != null)
            {
                Testimonial xdb = db.Testimonials.FirstOrDefault(w => w.Id == id);


                if (xdb.isActive == false)
                {
                    xdb.isActive = true;
                }
                else
                {
                    xdb.isActive = false;
                }



                db.Entry(xdb).State = EntityState.Modified;
                db.SaveChanges();

                result = true;
            }



            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Пример #24
0
        public Boolean create_testimonial(Testimonial testimonial)
        {
            SqlConnection conn    = new SqlConnection();
            Boolean       success = false;

            //DateTime time = ;
            try
            {
                conn = new SqlConnection();
                string connstr = ConfigurationManager.ConnectionStrings["DBConnectionString"].ToString();
                conn.ConnectionString = connstr;
                conn.Open();
                SqlCommand comm = new SqlCommand();
                comm.Connection  = conn;
                comm.CommandText = "insert into [Testimonials] values (@name, @quote, @id, @course, @title)";
                comm.Parameters.AddWithValue("@name", testimonial.getStaffName());
                comm.Parameters.AddWithValue("@quote", testimonial.getQuote());
                comm.Parameters.AddWithValue("@id", testimonial.getUser().getUserID());
                //comm.Parameters.AddWithValue("@date", DateTime.Now);
                comm.Parameters.AddWithValue("@course", testimonial.getCourse_elearn().getCourseID());
                comm.Parameters.AddWithValue("@title", testimonial.getTitle());
                //comm.Parameters.AddWithValue("@content", course.getCourseID());
                int rowsAffected = comm.ExecuteNonQuery();
                success = true;
            }
            catch (SqlException ex)
            {
                throw ex;
            }
            finally
            {
                conn.Close();
            }
            return(success);
        }
    protected void RpTestimonial_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        string strCommand = e.CommandName;
            int nID = ConvertData.ConvertToInt(e.CommandArgument);
            Testimonial objTestimonial = new Testimonial();
            switch (strCommand)
            {
                case "Delete":
                    int nDelete = objTestimonial.DeleteById(nID);

                    BindData(1);
                    break;

                case "Edit":
                    string sEdit = Constants.ROOT + Pages.BackEnds.ADMIN + "?" + Constants.PAGE + "=" + Pages.BackEnds.STR_TESTIMONIAL_ADD + "&" + Constants.ACTION + "=" + Constants.ACTION_EDIT + "&" + Constants.ACTION_ID + "=" + nID;
                    Response.Redirect(sEdit);
                    break;

                case "Active":
                    int nActive = objTestimonial.UpdateStatus(nID, EnumeType.INACTIVE);

                    BindData(1);
                    break;

                case "Inactive":
                    int nInactive = objTestimonial.UpdateStatus(nID, EnumeType.ACTIVE);

                    BindData(1);
                    break;
            }
    }
Пример #26
0
        public ActionResult Create(Testimonial testimonial)
        {
            if (ModelState.IsValid)
            {
                if (testimonial.ImageFile != null)
                {
                    string imageName = DateTime.Now.ToString("ddMMyyyyHHmmssfff") + testimonial.ImageFile.FileName;
                    string imagePath = Path.Combine(Server.MapPath("~/Uploads/"), imageName);

                    testimonial.ImageFile.SaveAs(imagePath);
                    testimonial.Image = imageName;
                }
                else
                {
                    ModelState.AddModelError("ImageFile", "Image is required");
                    return(View(testimonial));
                }
                testimonial.CreatedDate = DateTime.Now;

                db.Testimonials.Add(testimonial);
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }
            return(View(testimonial));
        }
Пример #27
0
 public IActionResult Create(Testimonial testimonial)
 {
     if (!ModelState.IsValid)
     {
         return(View());
     }
     if (testimonial.ImageFile != null)
     {
         if (testimonial.ImageFile.ContentType != "image/png" && testimonial.ImageFile.ContentType != "image/jpeg")
         {
             ModelState.AddModelError("ImageFile", "Jpeg ve ya png formatinda file daxil edilmelidir");
             return(View());
         }
         if (testimonial.ImageFile.Length > (1024 * 1024) * 5)
         {
             ModelState.AddModelError("ImageFile", "File olcusu 5mb-dan cox olmaz!");
             return(View());
         }
         string rootPath = _env.WebRootPath;
         var    fileName = Guid.NewGuid().ToString() + testimonial.ImageFile.FileName;
         var    path     = Path.Combine(rootPath, "uploads/testimonial", fileName);
         using (FileStream stream = new FileStream(path, FileMode.Create))
         {
             testimonial.ImageFile.CopyTo(stream);
         }
         testimonial.Image = fileName;
     }
     _context.Testimonials.Add(testimonial);
     _context.SaveChanges();
     return(RedirectToAction("index"));
 }
Пример #28
0
        public ActionResult Update(Testimonial testimonial)
        {
            if (ModelState.IsValid)
            {
                Testimonial Testimonial = db.Testimonials.Find(testimonial.Id);

                if (testimonial.ImageFile != null)
                {
                    string imageName = DateTime.Now.ToString("ddMMyyyyHHmmssfff") + testimonial.ImageFile.FileName;
                    string imagePath = Path.Combine(Server.MapPath("~/Uploads/"), imageName);

                    string oldImagePath = Path.Combine(Server.MapPath("~/Uploads/"), Testimonial.Image);
                    System.IO.File.Delete(oldImagePath);

                    testimonial.ImageFile.SaveAs(imagePath);
                    Testimonial.Image = imageName;
                }
                Testimonial.Fullname = testimonial.Fullname;
                Testimonial.Content  = testimonial.Content;
                Testimonial.Position = testimonial.Position;

                db.Entry(Testimonial).State = EntityState.Modified;
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }
            return(View(testimonial));
        }
        public async Task <JsonResult> Delete(int?id)
        {
            if (id != null)
            {
                Testimonial testimonial = await _context.Testimonials
                                          .Where(m => m.Id == id)
                                          .FirstOrDefaultAsync();


                if (testimonial != null)
                {
                    _context.Testimonials.Remove(testimonial);
                    await _context.SaveChangesAsync();

                    return(Json(new
                    {
                        status = 200
                    }));
                }
                else
                {
                    return(Json(new
                    {
                        status = 400
                    }));
                }
            }
            else
            {
                return(Json(new
                {
                    status = 400
                }));
            }
        }
Пример #30
0
        public void Create(TestimonialViewModel command)
        {
            var newtestimonial = new Testimonial(command.StudentName, command.StudentImg, command.StudentEmail, command.CourseName, command.UniversityName, command.EduYear, command.Title, command.Description);

            _irepository.Create(newtestimonial);
            _irepository.SaveChanges();
        }
        public async Task <IActionResult> Edit(List <string> Texts, int TestimonialId, string Name)
        {
            List <Language> languages = await _context.Languages.ToListAsync();

            Testimonial testimonial1 = await _context.Testimonials.Where(t => t.Id == TestimonialId).FirstOrDefaultAsync();

            testimonial1.Name = Name;
            for (int i = 0; i < languages.Count; i++)
            {
                TestimonialLanguage testimonialLanguage = await _context.TestimonialLanguages
                                                          .Where(sl => sl.TestimonialId == TestimonialId &&
                                                                 sl.LanguageId == languages[i].Id)
                                                          .FirstOrDefaultAsync();

                if (testimonialLanguage == null)
                {
                    TestimonialLanguage testimonial = new TestimonialLanguage()
                    {
                        TestimonialId = TestimonialId,
                        LanguageId    = languages[i].Id,
                        Text          = Texts[i],
                    };

                    await _context.TestimonialLanguages.AddAsync(testimonial);
                }
                else
                {
                    testimonialLanguage.Text = Texts[i];
                }
            }

            await _context.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }
Пример #32
0
        public IHttpActionResult FindTestimonial(int id)
        {
            Testimonial testimonial = db.Testimonials.Find(id);

            if (testimonial == null)
            {
                return(NotFound());
            }
            TestimonialDto NewTestimonial = new TestimonialDto
            {
                testimonial_Id      = testimonial.testimonial_Id,
                testimonial_Content = testimonial.testimonial_Content,
                first_Name          = testimonial.first_Name,
                last_Name           = testimonial.last_Name,
                email         = testimonial.email,
                phone_Number  = testimonial.phone_Number,
                Has_Pic       = testimonial.Has_Pic,
                Pic_Extension = testimonial.Pic_Extension,
                posted_Date   = testimonial.posted_Date,
                Approved      = testimonial.Approved,
                Id            = testimonial.Id
            };

            return(Ok(NewTestimonial));
        }
Пример #33
0
 public ActionResult Edit_Admin(int?id)
 {
     try
     {
         if (id == null)
         {
             return(RedirectToAction("Index_Admin"));;
         }
         Testimonial testimonial = db.Testimonials.Find(id);
         if (testimonial == null)
         {
             return(HttpNotFound());
         }
         ViewBag.departments = db.departments.ToList();
         return(View(testimonial));
     }
     catch (DbUpdateException dbException)
     {
         ViewBag.DbExceptionMessage = dbException.Message;
     }
     catch (SqlException sqlException)
     {
         ViewBag.SqlException = sqlException.Message;
     }
     catch (Exception genericException)
     {
         ViewBag.ExceptionMessage = genericException.Message;
     }
     return(View("~/Views/Errors/Details.cshtml"));
 }
        public HttpResponseMessage Post(Testimonial model)
        {
            model.created = DateTime.UtcNow;
            model = repo.createTestimonial(model);

            HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, model);
            response.Headers.Location = new Uri(Url.Link("ApiControllerAndId", new { id = model.id }));
            return response;
        }
Пример #35
0
 public static Testimonial Get(int id = 0)
 {
     Testimonial testimonial = new Testimonial();
     try {
         CurtDevDataContext db = new CurtDevDataContext();
         testimonial = db.Testimonials.Where(x => x.testimonialID == id).FirstOrDefault<Testimonial>();
     } catch {}
     return testimonial;
 }
Пример #36
0
 public string AddTestimonialAjax(string first_name = "", string last_name = "", string location = "", double rating = 0, string addtitle = "", string testimonial = "")
 {
     Testimonial t = new Testimonial();
     JavaScriptSerializer js = new JavaScriptSerializer();
     try {
         if (testimonial.Trim() == "" || addtitle.Trim() == "" || rating == 0) {
             throw new Exception();
         }
         t = TestimonialModel.Add(first_name, last_name, location, addtitle, testimonial, rating);
     } catch {}
     return js.Serialize(t);
 }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        string sContent = ConvertData.ConvertToString(txtcontent.Text);
        if (sContent != "")
        {

            int nActionResult = 0;
            int nCurrentLanguage = 1;
            Testimonial objTestimonial = new Testimonial();
            objTestimonial.Data = SetData();
            string sAction = GetQuerryString(Constants.ACTION);
            if (sAction == Constants.ACTION_EDIT)
            {
                //Is Edit
                int nItemID = ConvertData.ConvertToInt(Request.QueryString[Constants.ACTION_ID]);
                nActionResult = objTestimonial.Update(nItemID);
                if (nActionResult > 0)
                {
                    MessageBoxss.Show(MessagesAlert.UPDATE_SUCCESSFUL);

                }
                else
                {
                    MessageBoxss.Show(MessagesAlert.UPDATE_UNSUCCESSFUL);
                }
            }
            else
            {
                // Is Insert New

                nActionResult = objTestimonial.Insert();
                if (nActionResult > 0)
                {
                    string sURL = Constants.ROOT + Pages.BackEnds.ADMIN + "?" + Constants.PAGE + "=" + Pages.BackEnds.STR_TESTIMONIAL + "&" + Constants.MESS_ID + "=" + Constants.MESSAGE_INSERT;
                    Response.Redirect(sURL);
                }

            }
        }
        else
        {
            txtcontent.Focus();
            MessageBoxss.Show(MessagesValidate.NEWS_CONTENT_EMPTY);
        }
    }
Пример #38
0
        public static Testimonial Add(string first_name = "", string last_name = "", string location = "", string testimonial = "") {
            Testimonial t = new Testimonial();
            try {
                EcommercePlatformDataContext db = new EcommercePlatformDataContext();
                t = new Testimonial {
                    testimonial1 = testimonial,
                    first_name = first_name,
                    last_name = last_name,
                    location = location,
                    dateAdded = DateTime.UtcNow,
                    approved = false,
                    active = true,
                };
                db.Testimonials.InsertOnSubmit(t);
                db.SubmitChanges();
                return t;

            } catch {
                return t;
            }
        }
        public ActionResult Add(string first_name = "", string last_name = "", string location = "", string testimonial = "") {
            Testimonial t = new Testimonial {
                testimonial1 = testimonial,
                first_name = (first_name.Trim() == "") ? null : first_name.Trim(),
                last_name = (last_name.Trim() == "") ? null : last_name.Trim(),
                location = (location.Trim() == "") ? null : location.Trim()
            };
            string message = "";
            try {
                bool recaptchavalid = ReCaptcha.ValidateCaptcha(System.Web.HttpContext.Current, Request.Form["recaptcha_challenge_field"], Request.Form["recaptcha_response_field"]);
                if (!recaptchavalid) message += "Captcha was incorrect. ";
                if (testimonial.Trim() == "") message += "A Testimonial is required.";

                if (message.Length > 0) throw new Exception(message);
                t = TestimonialModel.Add(first_name, last_name, location, testimonial);
                return RedirectToAction("Add", "Testimonials", new { message = "Thanks for submitting a Testimonial!" });

            } catch (Exception e) { 
                message = e.Message;
                TempData["testimonial"] = t;
            }
            return RedirectToAction("Add", "Testimonials", new { message = message });
        }
Пример #40
0
        public static Testimonial Add(string first_name = "", string last_name = "", string location = "", string title = "", string testimonial = "", double rating = 0)
        {
            Testimonial t = new Testimonial();
            try {
                CurtDevDataContext db = new CurtDevDataContext();
                t = new Testimonial {
                    testimonial1 = testimonial,
                    first_name = first_name,
                    last_name = last_name,
                    location = location,
                    title = title,
                    rating = rating,
                    dateAdded = DateTime.Now,
                    approved = false,
                    active = true,
                };
                db.Testimonials.InsertOnSubmit(t);
                db.SubmitChanges();
                return t;

            } catch (Exception e) {
                return t;
            }
        }
    private void BindData(int CurrentPageIndex)
    {
        int nPageCount = 0;
        int nStatus =ConvertData.ConvertToInt(ddlStatus.SelectedValue);

        Testimonial objTestimonial = new Testimonial();
        DataTable dtbTestimonial = new DataTable();
        dtbTestimonial = objTestimonial.Search(CurrentPageIndex, Constants.PAGESIZE, ref nPageCount);
        RpTestimonial.DataSource = dtbTestimonial;
        RpTestimonial.DataBind();
        //lblTotalRecord.Text = "Có"[nDefLang - 1] + nPageCount + "Bản ghi được tìm thấy"[nDefLang - 1];
    }
        public HttpResponseMessage Put(int id, Testimonial model)
        {
            if (id != model.id)
            {
                return Request.CreateResponse(HttpStatusCode.BadRequest);
            }

            try
            {
                repo.update(model);
            }
            catch (DbUpdateConcurrencyException ex)
            {
                return Request.CreateErrorResponse(HttpStatusCode.NotFound, ex);
            }

            return Request.CreateResponse(HttpStatusCode.OK);
        }
    private void BindDataPriorityText()
    {
        DataTable dtbNews = new DataTable();
        Testimonial objNews = new Testimonial();

        dtbNews = objNews.SearchAll();
        int nCount = dtbNews.Rows.Count;
        string sAction = GetQuerryString(Constants.ACTION);//Lay Thong tin Edit, Insert
        int nRealValue = 0;
        if (sAction == Constants.ACTION_EDIT)//Kiem tra dieu kien
        {
            nRealValue = nCount;

            eTestimonial eProductsEntity = this.TestimonialEntity();
            string sPriority = ConvertData.ConvertToString(eProductsEntity.Priority);

            txtPriority.Text = sPriority;
        }
        else
        {
            nRealValue = nCount + 1;

            txtPriority.Text = ConvertData.ConvertToString(nRealValue);
        }
    }
 private eTestimonial TestimonialEntity()
 {
     eTestimonial entityNews = new eTestimonial();
     int nItemID = ConvertData.ConvertToInt(Request.QueryString[Constants.ACTION_ID]);
     string sQueery = ConvertData.ConvertToString(Request.QueryString[Constants.ACTION]);
     if (nItemID > 0 && sQueery == Constants.ACTION_EDIT)
     {
         Testimonial objTestimonial = new Testimonial();
         objTestimonial.LoadById(nItemID);
         entityNews = objTestimonial.Data;
     }
     return entityNews;
 }
    private eTestimonial SetData()
    {
        string sQueery = ConvertData.ConvertToString(Request.QueryString[Constants.ACTION]);
        eTestimonial eTestimonialEntity = this.TestimonialEntity();
        Testimonial objTestimonial = new Testimonial();
        if (chkActive.Checked) objTestimonial.Data.Status = Constants.STATUS_ACTIVE;
        else objTestimonial.Data.Status = Constants.STATUS_INACTIVE;

        objTestimonial.Data.ClientName = ConvertData.ConvertToString(txtFullname.Text);
        objTestimonial.Data.MainContent = ConvertData.ConvertToString(txtcontent.Text);
        objTestimonial.Data.ClientInfo = ConvertData.ConvertToString(txtClientInfo.Text);

        if (chkDisplayOrder.Checked) { objTestimonial.Data.Priority = ConvertData.ConvertToInt(txtPriority.Text); }
        else { objTestimonial.Data.Priority = 0; }

        objTestimonial.Data.Priority = ConvertData.ConvertToInt(txtPriority.Text);

        return objTestimonial.Data;
    }
    private void GetData( int ItemID)
    {
        // Get data to view on UI Controls
        int nStatus = 0;

        Testimonial objTestimonial = new Testimonial();
        objTestimonial.LoadById(ItemID);

        nStatus = ConvertData.ConvertToInt(objTestimonial.Data.Status);
        if (nStatus > 0)
            chkActive.Checked = true;
        else chkActive.Checked = false;

        int nDisplayOrder = 0;
        nDisplayOrder = ConvertData.ConvertToInt(objTestimonial.Data.Priority);
        if (nDisplayOrder > 0)
            chkDisplayOrder.Checked = true;
        else
            chkDisplayOrder.Checked = false;

        int nPriority = ConvertData.ConvertToInt(objTestimonial.Data.Priority);
        txtPriority.Text = ConvertData.ConvertToString(objTestimonial.Data.Priority);

        txtFullname.Text = objTestimonial.Data.ClientName;
        txtcontent.Text = (ConvertData.ConvertToString(objTestimonial.Data.MainContent));
        txtClientInfo.Text = (ConvertData.ConvertToString(objTestimonial.Data.ClientInfo));
    }
Пример #47
0
 public TestimonialVM()
 {
     Testimonial = new Testimonial();
     Accounts = new List<Account>();
     ImageSets = new List<ImageSet>();
 }
 public Testimonial createTestimonial(Testimonial model)
 {
     db.testimonials.Add(model);
     db.SaveChanges();
     return model;
 }