public ActionResult Edit(int? id)
 {
     var news = new AlumniNews();
     if (id != null && IsAuth)
     {
         news = _db.AlumniNewss.Find(id);
     }
     ViewBag.Status = news.Status.ToSelectList();
     FillAuthKeys();
     return View(news);
 }
 public ActionResult Edit(AlumniNews model)
 {
     return EditCommon(model);
 }
        private ActionResult EditCommon(AlumniNews model)
        {
            if (Request.Files.Count > 0)
            {
                HttpPostedFileBase file = Request.Files[0];
                if (file.ContentLength > 700 * 1024)
                {
                    ModelState.AddModelError("", "The maximum allowed picture size is 600KB");
                }
            }

            if (ModelState.IsValid)
            {
                if (IsAuth)
                {
                    var currUser = CurrentUser;
                    model.UserId = currUser.UserId;
                    model.UserName = currUser.FullName;
                    model.Status = currUser.IsAdmin() ? model.Status : PostStatusType.Pending;
                }
                else
                {
                    model.Status = PostStatusType.Pending;
                }

                if (Request.Files.Count > 0)
                {
                    HttpPostedFileBase file = Request.Files[0];
                    byte[] imageBytes = new byte[file.ContentLength];
                    file.InputStream.Read(imageBytes, 0, (int)file.ContentLength);
                    model.ImageType = file.FileName.Split('\\').Last();
                    model.ImageData = imageBytes;
                }

                if (model.EntityKey == 0)
                {
                    TempData[Constants.ViewBagMessageKey] = Strings.NewsPostSuccess;
                    _db.Entry(model).State = System.Data.EntityState.Added;
                }
                else
                {
                    _db.Entry(model).State = System.Data.EntityState.Modified;
                }

                _db.SaveChanges();
                return SafeRedirect();

            }
            FillAuthKeys();
            ViewBag.Status = model.Status.ToSelectList();
            ViewBag.NewsType = model.NewsType.ToSelectList();
            return View(model);
        }