public ActionResult ReturnRequestSubmit(int?reqId) { using (var db = new WebAppDbContext()) { using (var transaction = db.Database.BeginTransaction()) { var vm = new ConfigViewModel(); try { if (reqId != null) { var result = db.tbl_Request.Where(x => x.RequestId == reqId).FirstOrDefault(); if (result != null) { result.Status = 1; db.SaveChanges(); transaction.Commit(); } tbl_RequestLog req = new tbl_RequestLog(); req.RequestId = reqId; req.Status = 1; req.Remarks = "Again Submitted"; req.CurrentDateTime = DateTime.Now; req.UserId = System.Web.HttpContext.Current.User.Identity.GetUserId(); db.tbl_RequestLog.Add(req); db.SaveChanges(); } // Alert("Record Deleted Sucessfully!!!", NotificationType.success); return(RedirectToAction("RequestReturn")); } catch (Exception ex) { transaction.Rollback(); Exception(ex); Alert("Their is something went wrong!!!", NotificationType.error); return(RedirectToAction("RequestReturn")); } } } }
public ActionResult ReturnRequest(int?reqId, string remarks) { using (var db = new WebAppDbContext()) { try { if (reqId != null) { var result = db.tbl_Request.Where(x => x.RequestId == reqId).FirstOrDefault(); if (result != null) { result.Status = 3; db.Entry(result).Property(x => x.Status).IsModified = true; db.SaveChanges(); } tbl_RequestLog req = new tbl_RequestLog(); req.RequestId = reqId; req.Status = 3; req.Remarks = remarks; req.CurrentDateTime = DateTime.Now; req.UserId = System.Web.HttpContext.Current.User.Identity.GetUserId(); db.tbl_RequestLog.Add(req); db.SaveChanges(); } Alert("Request return Sucessfully!!!", NotificationType.success); return(RedirectToAction("Inbox")); } catch (Exception ex) { Exception(ex); Alert("Their is something went wrong!!!", NotificationType.error); return(RedirectToAction("Inbox")); } } }
public ActionResult RequestForm(tbl_Request tbl_Request, FileHelper FileHelper) { using (var db = new WebAppDbContext()) { using (var transaction = db.Database.BeginTransaction()) { try { if (!ModelState.IsValid) { var vm = new ConfigViewModel { _tbl_Country = db.tbl_Country.ToList(), _tbl_Currency = db.tbl_Currency.ToList() }; return(View("RequestForm", vm)); } if (FileHelper.File != null) { string savaPath = ""; string tempPath = ""; tempPath = "~/Images/Config"; savaPath = Server.MapPath(tempPath); if (!Directory.Exists(savaPath)) { Directory.CreateDirectory(savaPath); } var fileName = Path.GetFileNameWithoutExtension(FileHelper.File.FileName); var fileExtension = Path.GetExtension(FileHelper.File.FileName); string image = @"\" + fileName + DateTime.Now.Ticks + fileExtension; tbl_Request.PICTURE_FILE_NAME = image; tbl_Request.FileExtension = fileExtension; tbl_Request.File_Path = savaPath; FileHelper.File.SaveAs(savaPath + image); } // Get Current user Id var userId = System.Web.HttpContext.Current.User.Identity.GetUserId(); tbl_Request.CreatedByUser = userId; tbl_Request.ModifiedByUser = userId; //Get Current Date & Time. tbl_Request.CreatedOnDate = DateTime.Now; tbl_Request.ModifiedOnDate = DateTime.Now; tbl_Request.Status = 1; db.tbl_Request.Add(tbl_Request); db.SaveChanges(); tbl_RequestLog req = new tbl_RequestLog(); req.RequestId = tbl_Request.RequestId; req.Status = 1; req.Remarks = "NA"; req.CurrentDateTime = DateTime.Now; req.UserId = userId; db.tbl_RequestLog.Add(req); db.SaveChanges(); transaction.Commit(); Alert("Request Submitted Sucessfully!!!", NotificationType.success); return(RedirectToAction("RequestForm")); } catch (Exception ex) { transaction.Rollback(); Exception(ex); Alert("Their is something went wrong!!!", NotificationType.error); return(RedirectToAction("RequestForm")); } } } }