// GET: Admin/CurrentExComMembers/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CurrentExComMember currentExComMember = db.CurrentExComMembers.Find(id); //Below Lines added for Community var userid = User.Identity.GetUserId(); var currentExComMembera = from item in db.CurrentExComMembers where (item.CurrentExComMemberId == id) select item; currentExComMembera = currentExComMembera.Include(a => a.CreatedBy); currentExComMembera = currentExComMembera.Where(a => a.CreatedBy == userid); if (currentExComMembera.Count() == 0) { currentExComMember = null; } if (currentExComMember == null) { return(HttpNotFound()); } return(View(currentExComMember)); }
public ActionResult DeleteConfirmed(int id) { CurrentExComMember currentExComMember = db.CurrentExComMembers.Find(id); db.CurrentExComMembers.Remove(currentExComMember); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Create([Bind(Include = "CurrentExComMemberId,Name,Position,number,ImageUrl,Year,Linkedin,Facebook,Email,Mobile,Landline,Address,DOB,UniqueId,CreatedDate,CreatedBy,ModifiedDate,ModifiedBy,DelFlg")] CurrentExComMember currentExComMember, HttpPostedFileBase ImageUrl) { if (ModelState.IsValid) { db.Entry(currentExComMember).State = EntityState.Added; currentExComMember.CreatedBy = User.Identity.GetUserId(); currentExComMember.CreatedDate = DateTime.Now; if (ImageUrl != null) { string pathToCreate = "~/Images/currentExComMember"; if (!Directory.Exists(Server.MapPath(pathToCreate))) { //Now you know it is ok, create it Directory.CreateDirectory(Server.MapPath(pathToCreate)); } string extension = Path.GetExtension(ImageUrl.FileName); string fileName = Path.GetFileNameWithoutExtension(ImageUrl.FileName); string id = Guid.NewGuid().ToString(); string imageUrl = "/Images/currentExComMember/" + fileName + "" + /*main.MainId.ToString()*/ id + extension; ImageUrl.SaveAs(Path.Combine(Server.MapPath(pathToCreate), fileName + "" + /*main.MainId.ToString()*/ id + extension)); string DestinationPath = Path.Combine(Server.MapPath(pathToCreate)); DestinationPath += "\\" + fileName + id; ImageResizer.ImageJob i = new ImageResizer.ImageJob(DestinationPath + extension, DestinationPath + "_thumb.jpg", new ImageResizer.ResizeSettings( "width=200;height=200;format=jpg;mode=max")); i.Build(); currentExComMember.ImageUrl = imageUrl; db.CurrentExComMembers.Add(currentExComMember); } else { db.CurrentExComMembers.Add(currentExComMember); db.SaveChanges(); return(RedirectToAction("Index")); } db.SaveChanges(); return(RedirectToAction("Index")); } return(View(currentExComMember)); }