public ActionResult Delete(int Id) { TestimonialHelper _helper = new TestimonialHelper(); TestimonialModel testimonialModel = new TestimonialModel(); testimonialModel = _helper.GetByID(Id); int count = _helper.Delete(testimonialModel); if (count == 0) { string filePath = Server.MapPath("~/Content/Resources/Testimonial") + "/" + testimonialModel.ImageFile; if (System.IO.File.Exists(filePath)) { System.IO.File.Delete(filePath); } // delete the file from s3 AwsS3Bucket.DeleteObject("resources/testimonial/" + testimonialModel.ImageFile); TempData["CommonMessage"] = AppLogic.setMessage(count, "Record deleted successfully."); } else { TempData["CommonMessage"] = AppLogic.setMessage(count, "Record deletion failed."); } return(RedirectToAction("Index")); }
public IHttpActionResult Put(int id, [FromBody] TestimonialModel testimonialModel) { var result = new Result <String>(); using (var db = new jupiterEntities()) { var a = db.Testimonials.Where(x => x.TestimonialId == id).Select(x => x).FirstOrDefault(); if (a == null) { return(Json(DataNotFound(result))); } Type type = typeof(Testimonial); UpdateTable(testimonialModel, type, a); try { db.SaveChanges(); } catch (Exception e) { result.ErrorMessage = e.Message; result.IsSuccess = false; return(Json(result)); } } return(Json(result)); }
public TestimonialModel GetTestimonialSpecificDetails(Hashtable testimonialCriteria) { var _db = new DBUtility(); var temp = new TestimonialModel(); var _dt = new DataTable(); _cmd = new SqlCommand(); _cmd.CommandType = CommandType.StoredProcedure; _cmd.CommandText = "GP_SP_GetTestimonialSpecificDetails"; _cmd.Parameters.AddWithValue("@TestimonialID", Convert.ToInt32(testimonialCriteria["ID"])); _dt = _db.FillDataTable(_cmd, _dt); if (_dt.Rows.Count > 0) { foreach (DataRow dr in _dt.Rows) { temp.ID = Convert.ToInt32(dr["ID"]); temp.Author = Convert.ToString(dr["Author"]); temp.Description = Convert.ToString(dr["Description"]); temp.ImagePath = Convert.ToString(dr["ImagePath"]); temp.IsActive = Convert.ToBoolean(dr["IsActive"]); } } return(temp); }
public ActionResult Edit(int id) { try { Models.TestimonialModel testimonialmodel = new TestimonialModel() { TestimonialId = 0 }; CLayer.Testimonial testimonial = BLayer.Testimonial.Get(id); if (testimonial != null) { testimonialmodel = new TestimonialModel() { TestimonialId = testimonial.TestimonialId, Name = testimonial.Name, Company = testimonial.Company, Picture = testimonial.Picture, Title = testimonial.Title, Description = testimonial.Description, Status = testimonial.Status, ShowInWidget = testimonial.ShowInWidget }; ViewBag.Head = testimonial.Title; } return(View("Edit", testimonialmodel)); } catch (Exception ex) { Common.LogHandler.HandleError(ex); return(Redirect("~/Admin/ErrorPage")); } }
public int Delete(TestimonialModel objectModel) { int count = -1; // check the langauge id if exists in another table //if (!context.tblMemberships.Any(o => o.MembershipId == objectModel.FaqCategoryId)) //{ // count = -2; // return count; //} tblTestimonial tblTestimonialDb = new tblTestimonial(); tblTestimonialDb.TestimonialId = objectModel.TestimonialId; context.Entry(tblTestimonialDb).State = EntityState.Deleted; count = context.SaveChanges(); if (count == 1) { count = 0; } else { count = -1; } return(count); }
public int AddUpdate(TestimonialModel objectModel) { if (objectModel.TestimonialId > 0) { if (context.tblTestimonials.Any(x => x.AuthorName == objectModel.AuthorName && x.Designation == objectModel.Designation && x.TestimonialId != objectModel.TestimonialId)) { return(1); } else { return(update(objectModel)); } } else { if (context.tblTestimonials.Any(x => x.AuthorName == objectModel.AuthorName && x.Designation == objectModel.Designation)) { return(1); } else { return(update(objectModel)); } } }
public async Task CreateNewTestimonial(CreateTestimonialDto createTestimonialDto) { var testimonialCode = _databaseContext.TestimonialCodes.FirstOrDefault(tc => tc.Code == createTestimonialDto.TestimonialCode); if (testimonialCode == null) { throw new TestimonialCodeDoesNotExistException(); } if (DateTime.Now > testimonialCode.ExpirationDateTime) { _databaseContext.TestimonialCodes.Remove(testimonialCode); await _databaseContext.SaveChangesAsync(); throw new TestimonialCodeExpiredException(); } var testimonial = new TestimonialModel(testimonialCode.FirstName, testimonialCode.LastName, testimonialCode.Description, createTestimonialDto.Testimonial); await _databaseContext.Testimonials.AddAsync(testimonial); _databaseContext.TestimonialCodes.Remove(testimonialCode); await _databaseContext.SaveChangesAsync(); }
public ActionResult SaveTestimonialDetails(TestimonialModel testimonialModel) { var serialization = new Serialization(); var testimonialBA = new Testimonial(); var HashCriteria = new Hashtable(); var TestimonialDetails = new TestimonialModel(); var actualCriteria = string.Empty; if (ModelState.IsValid) { HashCriteria.Add("ID", testimonialModel.ID); HashCriteria.Add("Author", testimonialModel.Author); var description = Sanitizer.GetSafeHtml(testimonialModel.Description); HashCriteria.Add("Description", description); HashCriteria.Add("UserID", userID); actualCriteria = serialization.SerializeBinary((object)HashCriteria); var result = testimonialBA.SaveTestimonialDetails(actualCriteria); var testimonialID = Convert.ToInt32(serialization.DeSerializeBinary(Convert.ToString(result))); SaveTestimonialImages(testimonialID); Session["TestimonialImages"] = null; if (testimonialModel.ID <= 0) { TempData["TestimonialSuccess"] = "Testimonial details has been saved successfully..!"; } else { TempData["TestimonialSuccess"] = "Testimonial details has been modified successfully..!"; } } return(RedirectToAction("Admin", "Dashboard")); }
public bool CreateTestimonial(TestimonialModel testimonial) { var isSuccess = true; try { using (_context) { tTestimonial test = new tTestimonial(); test.Active = true; test.ByName = testimonial.ByName; test.Location = testimonial.Location; test.Testimonial = testimonial.Testimonial; test.TestimonialId = Guid.NewGuid(); _context.tTestimonials.Add(test); _context.SaveChanges(); } } catch (Exception ex) { isSuccess = false; } return(isSuccess); }
public async Task <DIBZ.Common.Model.Testimonial> AddTestimonial(TestimonialModel request) { DIBZ.Common.Model.Testimonial testimonial = null; testimonial.Description = request.Description; await Db.SaveAsync(); return(testimonial); }
public ActionResult Edit(int Id) { TestimonialHelper _Helper = new TestimonialHelper(); TestimonialModel testimonialModel = new TestimonialModel(); testimonialModel = _Helper.GetByID(Id); ViewBag.StatusList = AppLogic.BindDDStatus(Convert.ToInt32(testimonialModel.Status)); return(View(testimonialModel)); }
private ActionResult BindList() { TestimonialHelper _Helper = new TestimonialHelper(); TestimonialModel testimonialModel = new TestimonialModel(); var List = _Helper.GetAll(); ActiveList = List.Where(x => x.Status == 1).ToList(); InActiveList = List.Where(x => x.Status == 0).ToList(); return(View(Tuple.Create(ActiveList, InActiveList, testimonialModel))); }
public async Task <ActionResult> Add(TestimonialModel request) { if (TryValidateModel(request)) { var testimonialLogic = LogicContext.Create <TestimonialLogic>(); await testimonialLogic.AddTestimonial(request); return(RedirectToAction("Index", "Testimonial")); } return(View("Index", request)); }
public int update(TestimonialModel objectModel) { tblTestimonial tblTestimonialDb = new tblTestimonial(); tblTestimonialDb.TestimonialId = objectModel.TestimonialId; tblTestimonialDb.AuthorName = objectModel.AuthorName; tblTestimonialDb.Designation = objectModel.Designation; tblTestimonialDb.Description = objectModel.Description; tblTestimonialDb.DisplayOrder = objectModel.DisplayOrder; tblTestimonialDb.Status = objectModel.Status; tblTestimonialDb.ImageFile = objectModel.ImageFile; tblTestimonialDb.ActualImageFile = objectModel.ActualImageFile; if (objectModel.TestimonialId > 0) { tblTestimonialDb.ModifiedBy = AdminSessionData.AdminUserId; tblTestimonialDb.ModifiedOn = DateTime.Now; tblTestimonialDb.ModifiedFromIP = HttpContext.Current.Request.UserHostAddress; context.tblTestimonials.Attach(tblTestimonialDb); context.Entry(tblTestimonialDb).Property(x => x.AuthorName).IsModified = true; context.Entry(tblTestimonialDb).Property(x => x.Designation).IsModified = true; context.Entry(tblTestimonialDb).Property(x => x.Description).IsModified = true; context.Entry(tblTestimonialDb).Property(x => x.DisplayOrder).IsModified = true; context.Entry(tblTestimonialDb).Property(x => x.ImageFile).IsModified = true; context.Entry(tblTestimonialDb).Property(x => x.ActualImageFile).IsModified = true; context.Entry(tblTestimonialDb).Property(x => x.Status).IsModified = true; context.Entry(tblTestimonialDb).Property(x => x.ModifiedBy).IsModified = true; context.Entry(tblTestimonialDb).Property(x => x.ModifiedOn).IsModified = true; context.Entry(tblTestimonialDb).Property(x => x.ModifiedFromIP).IsModified = true; } else { tblTestimonialDb.CreatedBy = AdminSessionData.AdminUserId; tblTestimonialDb.CreatedOn = DateTime.Now; tblTestimonialDb.CreatedFromIp = HttpContext.Current.Request.UserHostAddress; context.tblTestimonials.Add(tblTestimonialDb); } int count = context.SaveChanges(); if (count == 1) { count = 0; } else { count = -1; } return(count); }
public IHttpActionResult PostTestimonial(TestimonialModel data) { try { var result = oSvc.PostTestimonial(data); return(Ok(result)); } catch (Exception ex) { ExceptionModel exc = oException.Set(ex); return(Ok(exc)); } }
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 })); }
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) { TestimonialModel testModel = new TestimonialModel(); DataContext = testModel; string strItemIndex; if (NavigationContext.QueryString.TryGetValue("index", out strItemIndex)) { testimonials.SelectedIndex = Convert.ToInt32(strItemIndex); } base.OnNavigatedTo(e); }
public IActionResult Testimonial(int p) { TestimonialModel model = new TestimonialModel(); if (p == 0) { p = 1; } var dummyTestimonial = _classBookService.GetAllTestimonials(); model.Pager = new Pager(dummyTestimonial.Count, p, 2, 2); model.Testimonials = _classBookModelFactory.PrepareTestimonial(_classBookService.GetAllTestimonials(false, p, 2)); return(View(model)); }
public ActionResult UpdateTestimonial(TestimonialModel model) { DatabaseService service = new DatabaseService(); var isSuccess = service.UpdateTestimonial(model); if (isSuccess) { return(Json(new { Response = "Success" })); } else { return(Json(new { Response = "Error" })); } }
public List <TestimonialModel> GetallTestimonial(Hashtable testimonialCriteria) { var _db = new DBUtility(); var token = new List <TestimonialModel>(); var _dt = new DataTable(); _cmd = new SqlCommand(); _cmd.CommandType = CommandType.StoredProcedure; _cmd.CommandText = "GP_SP_GetAllTestimonial"; if (string.IsNullOrWhiteSpace(Convert.ToString(testimonialCriteria["SearchText"]))) { _cmd.Parameters.AddWithValue("@SearchText", DBNull.Value); } else { _cmd.Parameters.AddWithValue("@SearchText", Convert.ToString(testimonialCriteria["SearchText"])); } if (string.IsNullOrWhiteSpace(Convert.ToString(testimonialCriteria["SortingOrder"]))) { _cmd.Parameters.AddWithValue("@SortingOrder", DBNull.Value); } else { _cmd.Parameters.AddWithValue("@SortingOrder", Convert.ToString(testimonialCriteria["SortingOrder"]).Trim()); } _dt = _db.FillDataTable(_cmd, _dt); if (_dt.Rows.Count > 0) { foreach (DataRow dr in _dt.Rows) { var temp = new TestimonialModel(); temp.ID = Convert.ToInt32(dr["ID"]); temp.Author = Convert.ToString(dr["Author"]); temp.Description = Convert.ToString(dr["Description"]); temp.ImagePath = Convert.ToString(dr["ImagePath"]); temp.IsActive = Convert.ToBoolean(dr["IsActive"]); temp.CreatedDate = Convert.ToDateTime(dr["CreatedDate"]); temp.ModifiedDate = Convert.ToDateTime(dr["ModifiedDate"]); token.Add(temp); } } return(token); }
public ActionResult Details(string testimonialID) { var serialization = new Serialization(); var testimonialBA = new Testimonial(); var HashCriteria = new Hashtable(); var actualCriteria = string.Empty; var testimonialModel = new TestimonialModel(); var testimonial_ID = Convert.ToInt32(CipherTool.DecryptString(testimonialID)); HashCriteria.Add("ID", testimonial_ID); actualCriteria = serialization.SerializeBinary((object)HashCriteria); var result = testimonialBA.EditTestimonialDetails(actualCriteria); testimonialModel = (TestimonialModel)(serialization.DeSerializeBinary(Convert.ToString(result))); ViewBag.Logo = CheckFileExists(testimonialModel.ImagePath, "TestimonialImagePath", Convert.ToString(testimonial_ID)); return(View("SingleTestimonialDetails", testimonialModel)); }
public ActionResult NewInactive() { try { ViewBag.Head = "New Testimonial"; Models.TestimonialModel testimonialmodel = new TestimonialModel() { TestimonialId = 0, Status = (int)Models.TestimonialModel.StatusList.Disabled }; return(View("Edit", testimonialmodel)); } catch (Exception ex) { Common.LogHandler.HandleError(ex); return(Redirect("~/Admin/ErrorPage")); } }
public ActionResult Delete(string testimonialID, int?page) { var serialization = new Serialization(); var testimonialBA = new Testimonial(); var HashCriteria = new Hashtable(); var actualCriteria = string.Empty; var TestimonialModel = new TestimonialModel(); var testimonial_ID = Convert.ToInt32(CipherTool.DecryptString(testimonialID)); HashCriteria.Add("ID", testimonial_ID); HashCriteria.Add("UserID", userID); actualCriteria = serialization.SerializeBinary((object)HashCriteria); var resultTestimonial = testimonialBA.DeleteCurrentTestimonial(actualCriteria); var result = (Convert.ToInt32(serialization.DeSerializeBinary(Convert.ToString(resultTestimonial)))); return(Json(result, JsonRequestBehavior.AllowGet)); }
public ActionResult CreateTestimonial(FormCollection collection) { var name = collection["Name"].ToString(); var location = collection["Location"].ToString(); var testimonial = collection["Testimonial"].ToString(); TestimonialModel model = new TestimonialModel(); model.ByName = name; model.Location = location; model.Testimonial = testimonial; DatabaseService service = new DatabaseService(); var isSuccess = service.CreateTestimonial(model); return(RedirectToAction("Manage", "Testimonial")); }
// GET: api/Testimonial/5 public IHttpActionResult Get(int id) { var result = new Result <TestimonialModel>(); using (var db = new jupiterEntities()) { Testimonial testimonial = db.Testimonials.Find(id); TestimonialModel testimonialModel = new TestimonialModel(); if (testimonial == null) { return(Json(DataNotFound(result))); } Mapper.Map(testimonial, testimonialModel); result.Data = testimonialModel; } return(Json(result)); }
public IHttpActionResult PutTestimonial(int?id, TestimonialModel data) { try { if (!id.HasValue) { return(BadRequest()); } var result = oSvc.PutTestimonial(id.Value, data); return(Ok(result)); } catch (Exception ex) { ExceptionModel exc = oException.Set(ex); return(Ok(exc)); } }
public ActionResult Deactive(int Id) { TestimonialHelper _helper = new TestimonialHelper(); TestimonialModel testimonialModel = new TestimonialModel(); testimonialModel.TestimonialId = Id; testimonialModel.Status = 0; int count = _helper.ActDeact(testimonialModel); if (count == 0) { TempData["CommonMessage"] = AppLogic.setMessage(count, "Record deactivated successfully."); } else { TempData["CommonMessage"] = AppLogic.setMessage(count, "Record deactivation failed."); } return(RedirectToAction("Index")); }
public async Task <ActionResult <Testimonial> > PostTestimonial(TestimonialModel testimonialModel) { var result = new Result <Testimonial>(); Testimonial testimonial = new Testimonial(); _mapper.Map(testimonialModel, testimonial); try { result.Data = testimonial; await _context.Testimonial.AddAsync(testimonial); await _context.SaveChangesAsync(); } catch (Exception e) { result.ErrorMessage = e.Message; result.IsFound = false; } return(Ok(result)); }
public IActionResult Comment(TestimonialModel model) { var currentUserEmail = User.Identity.Name; var currentUser = _unitOfWork.UserRepository .GetAll() .FirstOrDefault(u => u.Email == currentUserEmail); var comment = new Comment() { Content = model.Content, UserId = currentUser.Id, DateTime = DateTime.Now }; _unitOfWork.CommentRepository.Add(comment); //_unitOfWork.Commit(); return(RedirectToAction("About", "Home")); }
public bool PutTestimonial(int testimonialId, TestimonialModel data) { string xml = Helper.XmlSerializer <TestimonialModel>(data); using (var context = new SQLContext()) { SqlParameter[] param = new SqlParameter[3]; param[0] = new SqlParameter("@testimonialid", SqlDbType.Int); param[0].Value = testimonialId; param[1] = new SqlParameter("@data", SqlDbType.Xml); param[1].Value = xml; param[2] = new SqlParameter("@userid", SqlDbType.Int); param[2].Value = 0; context.Database.ExecuteSqlCommand( "[dbo].[s_put_testimonial] @testimonialid, @data, @userid", param); return(true); } }