public IActionResult Create(Models.TbWithdraw model) { if (ModelState.IsValid) { model.UserId = HttpContext.Session.GetInt32("UserId"); model.DateApplicant = DateTime.Now; model.StatusId = 1; var user = db.TbWithdraw.Add(model); db.SaveChanges(); return(RedirectToAction("DrowList")); } return(View()); }
public IActionResult Register(Models.TbUser model) { // ModelState.Remove(model.UserId); //if (ModelState.IsValid) // { var chk = db.TbUser.Where(a => a.Username == model.Username).FirstOrDefault(); if (chk != null) { ModelState.AddModelError("", "มีชื่อผู้ใช้นี้อยู้ในระบบเเล้ว"); //Clients.RegisterStartupScript(this.GetType(), "alert", "alert('มีชื่อผู้ใช้นี้อยู่แล้ว')",true); } else { if (model.File != null) { using (var memoryStream = new MemoryStream()) { model.File.CopyTo(memoryStream); model.Image = memoryStream.ToArray(); } } model.UserTypeId = 1; var user = db.TbUser.Add(model); db.SaveChanges(); if (ViewBag.UserId == null) { return(RedirectToAction("Login", "User")); } else { return(RedirectToAction("UserList", "User")); } } // } return(View(model)); }
public IActionResult CreateApproveY(int id) { var model = new Models.TbApprove(); model.ProjectId = id; model.UserId = HttpContext.Session.GetInt32("UserId"); model.ApprovalResultsId = 1; model.DateApprove = DateTime.Now; var data = db.TbApprove.Add(model); db.SaveChanges(); var data2 = db.TbWithdraw.Where(a => a.ProjectId == id).FirstOrDefault(); if (data2 != null) { data2.StatusId = 2; db.TbWithdraw.Update(data2); db.SaveChanges(); } return(RedirectToAction("Index", "Home")); }
public IActionResult CreatePrename(Models.TbPrename model) { db.TbPrename.Add(model); db.SaveChanges(); return(RedirectToAction("PrenameList")); }