public bool Update(string prevUsername, v_User newProps) { try { new DcDataContext().User_Update(prevUsername, newProps.Username, newProps.Fullname, newProps.IsAdmin); return(true); } catch { return(false); } }
public bool Insert(v_User props, string Password) { try { new DcDataContext().User_Insert(props.Username, Password, props.Fullname, props.IsAdmin); return(true); } catch { return(false); } }
public ActionResult New(v_User props, string Password, string Confirm) { if (Password != Confirm) { ViewData["Message"] = "کلمه عبور و تکرار آن همخوانی ندارند"; return(View()); } else { if (!new DbController.Model_User().Insert(props, Password)) { ViewData["Message"] = "خطا در تعریف کاربر جدید"; return(View()); } else { return(RedirectToRoute(new { action = "Index", controller = "Users" })); } } }
public ActionResult Update(string Id, v_User props) // Id is prevUsername { if (Convert.ToBoolean(Session["IsAdmin"].ToString()) || (!Convert.ToBoolean(Session["IsAdmin"].ToString()) && Session["Username"].ToString() == Id)) { if (!new DbController.Model_User().Update(Id, props)) { v_User user = new DbController.Model_User().Select().Where(x => x.Username == Id).FirstOrDefault(); ViewData["Message"] = "خطا در به روز رسانی اطلاعات کاربر عزیزمان"; return(View(user)); } else { return(RedirectToRoute(new { action = "Admin", controller = "Home" })); } } else { Response.StatusCode = 401; return(new EmptyResult()); } }
public static string SetAuthenticated(string username, string firstname, string lastname, string status, string serial_number, int time = 60) { if (string.IsNullOrEmpty(username)) { Authentication._User = null; Authentication._Token = null; return(null); } Authentication._Token = Securities.JWTEncode( new Authentication { username = username, firstname = firstname, lastname = lastname, status = status, serial_number = serial_number, exp = GetNow.AddMinutes(time).ToBinary() }); return(Authentication._Token); }
public static string SetAuthenticated(v_User custObj, int time = 60) { if (custObj == null) { Authentication._User = null; Authentication._Token = null; return(null); } Authentication._Token = Securities.JWTEncode( new Authentication { username = custObj.username, firstname = custObj.firstname, lastname = custObj.lastname, status = custObj.status_name, serial_number = custObj.serial_number, exp = GetNow.AddMinutes(time).ToBinary() }); Authentication._User = custObj; return(Authentication._Token); }