public async Task <IActionResult> Create(bool?isPop, [Bind("Name,Startdate,Enddate,State,Regardingobjectid,Regardingobjecttypeid,Regardingobjectname,Description")] Appointment appointment) { // 사용자에게 쓰기 권한이 있는지 체크 CreaetUserAuth(); if (_userAuth.Write.Equals("4-3")) { return(RedirectToAction("Error", "Home", new { errormessage = "UserauthError" })); } if (ModelState.IsValid) { appointment.Createdate = DateTime.Now; appointment.Createuser = HttpContext.Session.GetString("userId"); appointment.Modifydate = DateTime.Now; appointment.Modifyuser = HttpContext.Session.GetString("userId"); appointment.Ownerid = HttpContext.Session.GetString("userId"); appointment.Owner = _context.User.Single(x => x.Id == appointment.Ownerid); _context.Add(appointment); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } if (isPop == null) { ViewBag.isPop = false; } else { ViewBag.isPop = isPop; } ViewData["Ownerid"] = new SelectList(_context.User, "Id", "Id", appointment.Ownerid); // 사용자 권한 ViewData["Read"] = _userAuth.Read; ViewData["Write"] = _userAuth.Write; ViewData["Modify"] = _userAuth.Modify; ViewData["Delete"] = _userAuth.Delete; return(View(appointment)); }
public async Task <IActionResult> MasterCreate(bool isPop, [Bind("Name,Description,Isused")] OptionMaster optionMaster) { if (!CheckSystemUserAsync()) { return(RedirectToAction("Error", "Home", new { errormessage = "UserauthError" })); } if (ModelState.IsValid) { optionMaster.Createdate = DateTime.Now; optionMaster.Createuser = HttpContext.Session.GetString("userId"); optionMaster.Modifydate = DateTime.Now; optionMaster.Modifyuser = HttpContext.Session.GetString("userId"); optionMaster.Ownerid = HttpContext.Session.GetString("userId"); _context.Add(optionMaster); await _context.SaveChangesAsync(); return(RedirectToAction("Close", "Home")); } ViewBag.isPop = isPop; return(View(optionMaster)); }
public async Task <IActionResult> MenuCreate(bool isPop, Menu mainMenu) { if (!CheckSystemUserAsync()) { return(RedirectToAction("Error", "Home", new { errormessage = "UserauthError" })); } if (ModelState.IsValid) { try { mainMenu.Createdate = DateTime.Now; mainMenu.Createuser = HttpContext.Session.GetString("userId"); mainMenu.Modifydate = DateTime.Now; mainMenu.Modifyuser = HttpContext.Session.GetString("userId"); mainMenu.Isdeleted = false; if (_context.Menu.Any(e => e.Order == mainMenu.Order)) { // 기존의 순서가 존재하면 맨 뒤로 보내기 Menu exist = _context.Menu.SingleOrDefault(x => x.Order == mainMenu.Order); int menuCount = _context.Menu.Count(); exist.Order = menuCount + 1; _context.Update(exist); await _context.SaveChangesAsync(); } _context.Add(mainMenu); await _context.SaveChangesAsync(); return(View("Close", "Home")); } catch (Exception ex) { // 로그 string dd = ex.InnerException.Message; return(View("Close", "Home")); } } return(View("Close", "Home")); }