public async Task <IActionResult> Create([Bind("Id,Pw,Name,Engname,Email,Phone,Mobile,Department,Position,Excelauth,Level,Organizationid")] User user) { if (!CheckSystemUserAsync()) { return(RedirectToAction("Error", "Home", new { errormessage = "UserauthError" })); } if (ModelState.IsValid) { user.Createdate = DateTime.Now; user.Createuser = HttpContext.Session.GetString("userId"); user.Modifydate = DateTime.Now; user.Modifyuser = HttpContext.Session.GetString("userId"); user.Organization = _context.Organization.Single(x => x.Organizationid == user.Organizationid); // 시스템 관리자 여부 if (user.Level == "2-1") { user.Ismaster = true; } else { user.Ismaster = false; } _context.Add(user); await _context.SaveChangesAsync(); // 사용자 생성 후 해당 사용자에 대한 권한 추가(기본값은 없음) var submenuList = _context.SubMenu.ToList(); foreach (var item in submenuList) { UserAuth createdUserAuth = new UserAuth() { Createdate = DateTime.Now, Createuser = HttpContext.Session.GetString("userId"), Modifydate = DateTime.Now, Modifyuser = HttpContext.Session.GetString("userId"), Delete = "4-3", Modify = "4-3", Write = "4-3", Read = "4-3", Submenu = item, Submenuid = item.Id, User = user }; _context.Add(createdUserAuth); await _context.SaveChangesAsync(); } return(RedirectToAction("Index")); } ViewData["Department"] = new SelectList(_context.OptionMasterDetail, "Optionid", "Optionid", user.Department); return(View(user)); }
public async Task <IActionResult> Create([Bind("Name,Maker,Origin,Productcode")] Product product) { // 사용자 쓰기 권한 체크 CreaetUserAuth(); if (_userAuth.Write.Equals("4-3")) { return(RedirectToAction("Error", "Home", new { errormessage = "UserauthError" })); } if (ModelState.IsValid) { product.Createdate = DateTime.Now; product.Createuser = HttpContext.Session.GetString("userId"); product.Modifydate = DateTime.Now; product.Modifyuser = HttpContext.Session.GetString("userId"); product.Ownerid = HttpContext.Session.GetString("userId"); _context.Add(product); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } #region 생성에 실패할 경우 ViewData["Read"] = _userAuth.Read; ViewData["Write"] = _userAuth.Write; ViewData["Modify"] = _userAuth.Modify; ViewData["Delete"] = _userAuth.Delete; #endregion return(View(product)); }
public async Task <IActionResult> Create(Account account) { // 사용자 수정 권한 체크 CreaetUserAuth(); if (_userAuth.Write.Equals("4-3")) { return(RedirectToAction("Error", "Home", new { errormessage = "UserauthError" })); } if (ModelState.IsValid) { try { account.Createdate = DateTime.Now; account.Createuser = HttpContext.Session.GetString("userId"); account.Modifydate = DateTime.Now; account.Modifyuser = HttpContext.Session.GetString("userId"); account.Isdeleted = false; account.Ownerid = HttpContext.Session.GetString("userId"); _context.Add(account); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } catch (Exception ex) { // 로그 string dd = ex.InnerException.Message; View(); } } return(View()); }
public async Task <IActionResult> Create([Bind("Name,Memo")] Organization organization) { if (!CheckSystemUserAsync()) { return(RedirectToAction("Error", "Home", new { errormessage = "UserauthError" })); } // 사용자 쓰기 권한 체크 CreaetUserAuth(); if (_userAuth.Write.Equals("4-3")) { return(RedirectToAction("Error", "Home", new { errormessage = "UserauthError" })); } // 권한 ViewData["Read"] = _userAuth.Read; ViewData["Write"] = _userAuth.Write; ViewData["Modify"] = _userAuth.Modify; ViewData["Delete"] = _userAuth.Delete; if (ModelState.IsValid) { organization.Createdate = DateTime.Now; _context.Add(organization); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(organization)); }
public async Task <IActionResult> Create([Bind("Productid,Prices,Cost,Currency")] Price price) { // 사용자 쓰기 권한 체크 CreaetUserAuth(); if (_userAuth.Write.Equals("4-3")) { return(RedirectToAction("Error", "Home", new { errormessage = "UserauthError" })); } if (ModelState.IsValid) { price.Createdate = DateTime.Now; price.Createuser = HttpContext.Session.GetString("userId"); price.Modifydate = DateTime.Now; price.Modifyuser = HttpContext.Session.GetString("userId"); price.Ownerid = HttpContext.Session.GetString("userId"); price.Product = _context.Product.SingleOrDefault(x => x.Productid == price.Productid); _context.Add(price); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } #region 제품 만들기에 실패할 경우 ViewData["Productid"] = new SelectList(_context.Product, "Productid", "Createuser", price.Productid); ViewData["Read"] = _userAuth.Read; ViewData["Write"] = _userAuth.Write; ViewData["Modify"] = _userAuth.Modify; ViewData["Delete"] = _userAuth.Delete; #endregion return(View(price)); }
public async Task <IActionResult> Create([Bind("Name,Description,Startdate,Enddate,Type")] Holiday holiday) { // 사용자에게 쓰기 권한이 있는지 체크 CreaetUserAuth(); if (_userAuth.Write.Equals("4-3")) { return(RedirectToAction("Error", "Home", new { errormessage = "UserauthError" })); } if (ModelState.IsValid) { holiday.Createdate = DateTime.Now; holiday.Createuser = HttpContext.Session.GetString("userId"); holiday.Modifydate = DateTime.Now; holiday.Modifyuser = HttpContext.Session.GetString("userId"); holiday.Ownerid = HttpContext.Session.GetString("userId"); holiday.Owner = _context.User.Single(x => x.Id == holiday.Ownerid); holiday.Remaindate = 0; _context.Add(holiday); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewData["Ownerid"] = new SelectList(_context.User, "Id", "Id", holiday.Ownerid); return(View(holiday)); }
public async Task <IActionResult> Create(Todo todo) { //[Bind("Name,Description,Regardingobjectid,Startdate,Enddate,State")] CreaetUserAuth(); // 사용자에게 쓰기 권한이 있는지 체크 if (_userAuth.Write.Equals("4-3")) { return(RedirectToAction("Error", "Home", new { errormessage = "UserauthError" })); } if (ModelState.IsValid) { todo.Createdate = DateTime.Now; todo.Createuser = HttpContext.Session.GetString("userId"); todo.Modifydate = DateTime.Now; todo.Modifyuser = HttpContext.Session.GetString("userId"); todo.Ownerid = HttpContext.Session.GetString("userId"); todo.Owner = _context.User.Single(x => x.Id == todo.Ownerid); _context.Add(todo); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } // 사용자 권한 ViewData["Read"] = _userAuth.Read; ViewData["Write"] = _userAuth.Write; ViewData["Modify"] = _userAuth.Modify; ViewData["Delete"] = _userAuth.Delete; return(View(todo)); }
public async Task <IActionResult> Create([Bind("Contactid,Name,Department,Accountid,Email,Phone,Mobile,Detail,Bossid,Createdate,Createuser,Modifydate,Modifyuser,Isdeleted,Ownerid")] Contact contact) { CreaetUserAuth(); // 사용자 쓰기 권한 체크 if (_userAuth.Write.Equals("4-3")) { return(RedirectToAction("Error", "Home", new { errormessage = "UserauthError" })); } if (ModelState.IsValid) { contact.Createdate = DateTime.Now; contact.Createuser = HttpContext.Session.GetString("userId"); contact.Modifydate = DateTime.Now; contact.Modifyuser = HttpContext.Session.GetString("userId"); contact.Isdeleted = false; contact.Ownerid = HttpContext.Session.GetString("userId"); _context.Add(contact); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(contact)); }
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")); }
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> 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)); }