public bool DeleteUser(string userName) { try { var en = new Models.Entities(); aspnet_Users u = null; aspnet_Membership member = null; try { u = en.aspnet_Users.First(m => m.UserName == userName); member = en.aspnet_Membership.First(m => m.UserId == u.UserId); en.DeleteObject(member); en.DeleteObject(u); en.SaveChanges(); return(true); } catch { throw new ArgumentException("注销失败"); } } catch { throw; } }
public bool CreateMail(string from, string to, aspnet_Users user, out string msg) { bool res = false; var mail = new udovika_email(); msg = ""; try { if (!GetPermissionAccessMail(user)) { msg = "Недостаточно прав."; return(res); } else { mail = new udovika_email() { id = 0, from = from, to = to, date = DateTime.Now }; SaveMail(mail, user, out msg); res = true; msg = "Сообщение создано."; } } catch (Exception ex) { _debug(ex, mail, ""); msg = "Не удалось создать сообщение."; } return(res); }
public string SetValidationCode(string userName) { if (string.IsNullOrWhiteSpace(userName)) { throw new ArgumentNullException("用户名为空"); } try { var en = new Models.Entities(); aspnet_Users u = null; try { u = en.aspnet_Users.First(m => m.UserName == userName); } catch { throw new ArgumentException("用户名不存在"); } // set a 20-lengthed validation string (code), it's only validate in 24 hours u.ValidationCode = (new Utilities.RandString()).Generate(); u.validUntil = DateTime.Now.AddDays(1); en.ApplyCurrentValues("aspnet_Users", u); en.SaveChanges(); return(u.ValidationCode); } catch { throw; } }
public bool DeleteDocument(int id, aspnet_Users user, out string msg) { bool res = false; //var item = new udovika_contract(); try { if (!GetPermissionAccessDocument(user)) { msg = "Недостаточно прав."; return(res); } else { db.DeleteDocument(id); msg = "Документ удален."; res = true; } } catch (Exception ex) { _debug(ex, new { docId = id }, ""); msg = "Документ не удален."; } return(res); }
public bool DeleteMail(int id, aspnet_Users user, out string msg) { bool res = false; var item = new udovika_email(); try { if (!GetPermissionAccessMail(user)) { msg = "Недостаточно прав."; return(res); } else { db.DeleteMail(id); res = true; msg = "Сообщение удалено."; } } catch (Exception ex) { _debug(ex, new { }, ""); msg = "Ошибка. Сообщение не удалено."; } return(res); }
public bool EditDocument(int id, string value, aspnet_Users user, out string msg) { bool res = false; var doc = new udovika_contract(); msg = ""; try { if (!GetPermissionAccessDocument(user)) { msg = "Недостаточно прав для редактирования."; return(res); } else { doc = db.GetDocument(id); if (doc != null) { doc.number = value; SaveDocument(doc, user, out msg); res = true; } } } catch (Exception ex) { _debug(ex, doc, ""); } return(res); }
public bool CreateDocument(string name, aspnet_Users user, out string msg) { var res = false; var doc = new udovika_contract(); msg = ""; try { if (!GetPermissionAccessDocument(user)) { msg = "Недостаточно прав для редактирования."; return(false); } else { doc = new udovika_contract() { id = 0, number = name, date = DateTime.Now }; SaveDocument(doc, user, out msg); res = true; } } catch (Exception ex) { _debug(ex, doc, ""); } return(res); }
public motskin_documents Edit(Dictionary <string, string> parameters, aspnet_Users user, out string msg) { motskin_documents res; msg = ""; try { if (!_IsCanUserChange(user)) { msg = "Нет прав для данной операции"; return(null); } int id = RDL.Convert.StrToInt(parameters["id"].ToString(), 0); res = _db.GetDocuments().FirstOrDefault(x => x.id == id); if (res != null) { _fillDocument(res, parameters); _db.SaveDocument(res); // сохраняем в бд } } catch (Exception ex) { _debug(ex, new { userName = user.UserName }); res = null; msg = "Сбой при выполнении операции"; } return(res); }
public ActionResult Edit(string UserName, string bio, string fb, string ins, aspnet_Users user, HttpPostedFileBase image) { var author = db.aspnet_Users.Find(UserName); if (ModelState.IsValid) { tbl_photo photo = new tbl_photo(); if (image != null) { if (System.IO.File.Exists(Server.MapPath(author.tbl_photo.URL))) { System.IO.File.Delete(Server.MapPath(author.tbl_photo.URL)); } string pictureName = Guid.NewGuid().ToString().Replace("-", ""); string pictureExtension = Path.GetExtension(Request.Files[0].FileName); string pictureWay = "/Upload/images/" + pictureName + pictureExtension; Request.Files[0].SaveAs(Server.MapPath(pictureWay)); photo.URL = pictureWay; var imagecopy = db.tbl_photo.Add(photo); author.PhotoId = imagecopy.PhotoId; db.SaveChanges(); } author.Biography = bio; author.Facebook = fb; author.Instagram = ins; db.SaveChanges(); } return(View()); }
public IHttpActionResult Postaspnet_Users(aspnet_Users aspnet_Users) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.aspnet_Users.Add(aspnet_Users); try { db.SaveChanges(); } catch (DbUpdateException) { if (aspnet_UsersExists(aspnet_Users.UserId)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = aspnet_Users.UserId }, aspnet_Users)); }
public bool RemoveInvoiceStatus(int id, aspnet_Users user, out string msg) { msg = ""; bool res = false; try { if (!_canManageItem(user)) { msg = "Нет прав на удаление элемента"; res = false; } else { _db.DeleteInvoiceStatus(id); res = true; } } catch (Exception e) { _debug(e, new { }, "Ошибка возникла при удалении элемента"); res = false; } return(res); }
public vas_invoices CreateInvoice(int contractorID, aspnet_Users user, out string msg) { var res = new vas_invoices(); msg = ""; try { if (!_canManageInvoice(user)) { msg = "Нет прав для данной операции"; return(res = null); } res.number = _getRandomString(8); res.date = DateTime.Now; res.statusID = 1; res.contractorID = contractorID; res.comment = "Комментарий"; res.code = _getRandomString(8).ToLower(); db.SaveInvoice(res); } catch (Exception ex) { _debug(ex, new { contractorID = contractorID, userName = user.UserName }); res = null; msg = "Сбой при выполнеии операции"; } return(res); }
public motskin_mails Create(Dictionary <string, string> parameters, aspnet_Users user, out string msg) { motskin_mails res = null; msg = ""; try { if (!_IsCanUserChange(user)) { msg = "Нет прав для данной операции"; return(null); } var statusID = GetStatuses().FirstOrDefault(x => x.code == "created").id; Guid guid = Guid.NewGuid(); res = new motskin_mails { date = DateTime.Now, // дата неизменна mailStatusID = statusID, createdUnique = guid }; _fillMail(res, parameters); _db.SaveMail(res); // сохраняем в бд // и сразу же получаем из базы этот объект, чтобы узнать его id. motskin_mails item = _db.GetMails().FirstOrDefault(x => x.createdUnique == guid); _logChangeStatus(item, "Статус изменен " + user.UserName); } catch (Exception ex) { _debug(ex, new { userName = user.UserName }); msg = "Сбой при выполнении операции"; } return(res); }
public Boolean IsUserInAccessProfile(Guid userId, Guid featureId) { using (DockerDBEntities dockerDBEntities = new DockerDBEntities()) { aspnet_Users user = (from p in dockerDBEntities.aspnet_Users where p.UserId == userId select p).First(); if (user.FeatureAccessProfiles != null) { foreach (FeatureAccessProfile ap in user.FeatureAccessProfiles) { if (ap.FeatureId == featureId) { return(true); } } } if (user.aspnet_Roles != null) { foreach (aspnet_Roles ar in user.aspnet_Roles) { foreach (FeatureAccessProfile ap in ar.FeatureAccessProfiles) { if (ap.FeatureId == featureId) { return(true); } } } } } return(false); }
public bool DeleteInvoice(int id, aspnet_Users user, out string msg) { msg = ""; bool res = false; //var item = new udovika_invoice(); try { //item = db.GetInvoice(id); if (!GetPermissionAccessInvoice(user)) { msg = "Недостаточно прав."; return(res); } else { db.DeleteInvoice(id); msg = "Счет удален."; res = true; } } catch (Exception ex) { _debug(ex, new { invoiceId = id }, ""); msg = "Счет не удален."; } return(res); }
protected void Page_Load(object sender, EventArgs e) { // Check if the request is authenticated if (Request.IsAuthenticated) { // Find label from the loginView control Label userNameLbl = loginView.FindControl("userName") as Label; // Connect to DB to retrieve first name of the logged-in user using (OnlineAssessmentDBEntities db = new OnlineAssessmentDBEntities()) { // Find user by UUID aspnet_Users user = db.aspnet_Users.Find(Membership.GetUser().ProviderUserKey); // If the user is not a lecturer if (user.Lecturer_Profile == null && user.Student_Profile != null) { userNameLbl.Text = user.Student_Profile.firstName; } else if (user.Student_Profile == null && user.Lecturer_Profile != null) { userNameLbl.Text = user.Lecturer_Profile.firstName; } else { userNameLbl.Text = user.UserName; } } } }
public bool EditContractField(aspnet_Users userRol, int id, string code, string value, out string msg, Shtoda_contracts user) { bool res = false; var document = new Shtoda_contracts(); try { if (!_IsCanUserChange(userRol)) { msg = "Недостаточна прав для редактирования!"; } else { document = GetContract(id); if (document != null) { SaveContract(document); res = true; msg = "Успешно"; } else { msg = "Не удалось найти документ"; } } } catch (Exception ex) { _debug(ex, new { }, ""); msg = "Произошла ошибка, поле не изменено"; } return(res); }
public void SaveDocument(rosh_documents res, aspnet_Users user, out string msg) { msg = ""; try { if (!_CanChangeDocument(user)) { msg = "Нет прав для данной операции"; } else { db.SaveDocument(res); msg = "Документ успешно сохранен!"; int savedDocID = res.id; //ChangeDocument(savedDocID); } } catch (Exception ex) { //RDL.Debug.LogError(ex); _debug(ex, new { res }, ""); } }
public bool RemoveListForm(int id, aspnet_Users user, out string msg) { msg = ""; bool res; try { if (!_canManageItem(user)) { msg = "Нет прав на удаление элемента"; res = false; } else { //var item = _db.GetForm(id); //item.isDeleted = true; _db.DeleteListForm(id); res = true; } } catch (Exception e) { _debug(e, new { }, "Ошибка возникла при удалении элемента"); res = false; } return(res); }
protected void Page_Load(object sender, EventArgs e) { using (OnlineAssessmentDBEntities db = new OnlineAssessmentDBEntities()) { string studID = ""; try { studID = Page.RouteData.Values["id"].ToString(); } catch (Exception) { Response.Redirect("/lecturer/list"); } aspnet_Users student = db.aspnet_Users.Where(s => s.LoweredUserName.Equals(studID.ToLower())).FirstOrDefault(); if (student != null) { studInfoHeader.Text = $"{student.Student_Profile.firstName} {student.Student_Profile.lastName} - {student.UserName}"; } else { Response.Redirect("/lecturer/list"); } } }
public motskin_contractors Create(Dictionary <string, string> parameters, aspnet_Users user, out string msg) { motskin_contractors res; msg = ""; try { if (!_IsCanUserChange(user)) { msg = "Нет прав для данной операции"; return(null); } res = new motskin_contractors(); _fillContractor(res, parameters); _db.SaveContractor(res); // сохраняем в бд } catch (Exception ex) { _debug(ex, new { userName = user.UserName }); res = null; msg = "Сбой при выполнении операции"; } return(res); }
public IHttpActionResult Putaspnet_Users(Guid id, aspnet_Users aspnet_Users) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != aspnet_Users.UserId) { return(BadRequest()); } db.Entry(aspnet_Users).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!aspnet_UsersExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public vas_mails CreateMail(string from, string to, aspnet_Users user, out string msg) { var res = new vas_mails(); msg = ""; try { if (!_canManageMail(user)) { msg = "Нет прав для данной операции"; return(res = null); } res.from = from; res.to = to; res.trackNumber = _getRandomString(8);; res.date = DateTime.Now; res.statusID = 1; res.mailSystem = "Default Mail System"; res.comment = "Комментарий"; res.code = _getRandomString(8).ToLower(); db.SaveMail(res); } catch (Exception ex) { _debug(ex, new { from = from, to = to, userName = user.UserName }); res = null; msg = "Сбой при выполнеии операции"; } return(res); }
public bool CreateInvoice(string name, aspnet_Users user, out string msg) { bool res = false; var invoice = new udovika_invoice(); msg = ""; try { if (!GetPermissionAccessInvoice(user)) { msg = "Недостаточно прав."; return(false); } else { invoice = new udovika_invoice() { id = 0, number = name, date = DateTime.Now }; SaveInvoice(invoice, user, out msg); res = true; } } catch (Exception ex) { _debug(ex, invoice, ""); } return(res); }
public bool DeleteContractor(int id, aspnet_Users user, out string msg) { var res = false; msg = ""; try { var item = db.GetContractor(id); if (!_canManageContractor(user, item)) { msg = "У вас нет прав на данную операцию"; return(res); } if (!db.DeleteContractor(id)) { throw new Exception("Сбой при удалении записи с базы"); } res = true; } catch (Exception ex) { _debug(ex, new { contractorID = id, userName = user.UserName }); msg = "Сбой при выполнеии операции"; } return(res); }
public bool EditContractorField(int pk, string name, string value, aspnet_Users user, out string msg) { var res = false; msg = ""; try { var item = db.GetContractor(pk); if (!_canManageContractor(user, item)) { msg = "Нет прав для данной операции"; return(res); } item.name = value; db.SaveContractor(item); res = true; } catch (Exception ex) { _debug(ex, new { contractorID = pk, userName = user.UserName }); msg = "Сбой при выполнеии операции"; } return(res); }
public vas_contractors CreateContractor(string name, aspnet_Users user, out string msg) { var res = new vas_contractors(); msg = ""; try { if (!_canManageContractor(user)) { msg = "Нет прав для данной операции"; return(res = null); } res.name = name; res.isDeleted = false; res.code = _getRandomString(8).ToLower(); db.SaveContractor(res); } catch (Exception ex) { _debug(ex, new { name = name, userName = user.UserName }); res = null; msg = "Сбой при выполнеии операции"; } return(res); }
public bool RemoveContragent(int id, out string msg, aspnet_Users user) { msg = ""; bool res; try { if (!_canManageItem(user)) { msg = "Нет прав на удаление элемента"; res = false; } else { msg = "Контрагент удален"; _db.DeleteContragent(id); res = true; } } catch (Exception e) { _debug(e, new { }, "Ошибка возникла при удалении элемента"); res = false; } return(res); }
public bool RemoveDocument(int id, out string msg, aspnet_Users user) { msg = ""; bool res; try { if (!_canManageItem(user)) { msg = "Нет прав на удаление элемента"; res = false; } else { _db.GetDocument(id).isDeleted = true; _db.SaveDocumentLog(_logDocumentChanges(user, _db.GetDocument(id), "Документ удален")); res = true; } } catch (Exception e) { _debug(e, new { }, "Ошибка возникла при удалении элемента"); res = false; } return(res); }
public motskin_contractors Edit(Dictionary <string, string> parameters, aspnet_Users user, out string msg) { motskin_contractors res; msg = ""; try { if (!_IsCanUserChange(user)) { msg = "Нет прав для данной операции"; return(null); } int id = int.Parse(parameters["id"]); res = _db.GetContractors().FirstOrDefault(x => x.id == id); if (res != null) { _fillContractor(res, parameters); _db.SaveContractor(res); // сохраняем в бд } } catch (Exception ex) { _debug(ex, new { userName = user.UserName }); res = null; msg = "Сбой при выполнении операции"; } return(res); }
public UserViewModel(aspnet_Users user) { MembershipUser mu = Membership.GetUser(user.UserName); //UserName = user.UserName; //FistName = user.FirstName; //LastName = user.LastName; //HomePhone = user.HomePhone; //Mobile = user.Mobile; //Email = mu.Email; //Password = mu.GetPassword(); //ConfirmPassword = Password; }
public Res Check(Test t, ModelContainer data, aspnet_Users user) { int c = 0; bool Success = true; try { Test test = (ReadTests(x => x.TestId == t.TestId, data).Value as IEnumerable<Test>).First(); //сравнение вопросов у тестов for(int i = 0; i < test.Quastions.ToList().Count; i++) { int b = 1; for(int j = 0; j < test.Quastions.ToList()[i].Variants.Count; j++) { if (test.Quastions.ToList()[i].Variants.ToList()[j].IsValid != t.Quastions.ToList()[i].Variants.ToList()[j].IsValid) { b = 0; } } c += b; } //сохранение результатов, только если не уже не был пройден этот тест if (data.Results.FirstOrDefault(x => x.aspnet_Users.UserId == user.UserId && x.TestId == t.TestId) != null) return new Res(Success, data.Results.FirstOrDefault(x => x.aspnet_Users.UserId == user.UserId && x.TestId == t.TestId).Result1); Result r = data.Results.Create(); r.TestId = t.TestId; r.Test = test; r.Result1 = c; r.aspnet_Users = user; r.aspnet_Users_UserId = user.UserId; data.Results.Add(r); data.SaveChanges(); } catch (Exception e) { Success = false; } return new Res(Success, c); }
public int CreateAssociate(Associate associate, Guid membershipUserId) { var stubAspNetUser = new aspnet_Users { UserId = membershipUserId }; this.MomentaDb.aspnet_Users.Attach(stubAspNetUser); associate.aspnet_Users = stubAspNetUser; this.MomentaDb.Associates.AddObject(associate); this.MomentaDb.SaveChanges(); return associate.ID; }
/// <summary> /// Create a new aspnet_Users object. /// </summary> /// <param name="userId">Initial value of UserId.</param> /// <param name="userName">Initial value of UserName.</param> /// <param name="loweredUserName">Initial value of LoweredUserName.</param> /// <param name="isAnonymous">Initial value of IsAnonymous.</param> /// <param name="lastActivityDate">Initial value of LastActivityDate.</param> public static aspnet_Users Createaspnet_Users(global::System.Guid userId, string userName, string loweredUserName, bool isAnonymous, global::System.DateTime lastActivityDate) { aspnet_Users aspnet_Users = new aspnet_Users(); aspnet_Users.UserId = userId; aspnet_Users.UserName = userName; aspnet_Users.LoweredUserName = loweredUserName; aspnet_Users.IsAnonymous = isAnonymous; aspnet_Users.LastActivityDate = lastActivityDate; return aspnet_Users; }
/// <summary> /// Create a new aspnet_Users object. /// </summary> /// <param name="userId">Initial value of UserId.</param> /// <param name="username">Initial value of Username.</param> /// <param name="loweredUsername">Initial value of LoweredUsername.</param> /// <param name="applicationId">Initial value of ApplicationId.</param> /// <param name="password">Initial value of Password.</param> /// <param name="passwordFormat">Initial value of PasswordFormat.</param> /// <param name="passwordSalt">Initial value of PasswordSalt.</param> /// <param name="isApproved">Initial value of IsApproved.</param> /// <param name="isAnonymous">Initial value of IsAnonymous.</param> /// <param name="lastActivityDate">Initial value of LastActivityDate.</param> /// <param name="lastLoginDate">Initial value of LastLoginDate.</param> /// <param name="lastPasswordChangedDate">Initial value of LastPasswordChangedDate.</param> /// <param name="createDate">Initial value of CreateDate.</param> /// <param name="isLockedOut">Initial value of IsLockedOut.</param> /// <param name="lastLockoutDate">Initial value of LastLockoutDate.</param> /// <param name="failedPasswordAttemptCount">Initial value of FailedPasswordAttemptCount.</param> /// <param name="failedPasswordAttemptWindowStart">Initial value of FailedPasswordAttemptWindowStart.</param> /// <param name="failedPasswordAnswerAttemptCount">Initial value of FailedPasswordAnswerAttemptCount.</param> /// <param name="failedPasswordAnswerAttemptWindowStart">Initial value of FailedPasswordAnswerAttemptWindowStart.</param> public static aspnet_Users Createaspnet_Users( string userId, string username, string loweredUsername, string applicationId, string password, string passwordFormat, string passwordSalt, bool isApproved, bool isAnonymous, global::System.DateTime lastActivityDate, global::System.DateTime lastLoginDate, global::System.DateTime lastPasswordChangedDate, global::System.DateTime createDate, bool isLockedOut, global::System.DateTime lastLockoutDate, long failedPasswordAttemptCount, global::System.DateTime failedPasswordAttemptWindowStart, long failedPasswordAnswerAttemptCount, global::System.DateTime failedPasswordAnswerAttemptWindowStart) { aspnet_Users aspnet_Users = new aspnet_Users(); aspnet_Users.UserId = userId; aspnet_Users.Username = username; aspnet_Users.LoweredUsername = loweredUsername; aspnet_Users.ApplicationId = applicationId; aspnet_Users.Password = password; aspnet_Users.PasswordFormat = passwordFormat; aspnet_Users.PasswordSalt = passwordSalt; aspnet_Users.IsApproved = isApproved; aspnet_Users.IsAnonymous = isAnonymous; aspnet_Users.LastActivityDate = lastActivityDate; aspnet_Users.LastLoginDate = lastLoginDate; aspnet_Users.LastPasswordChangedDate = lastPasswordChangedDate; aspnet_Users.CreateDate = createDate; aspnet_Users.IsLockedOut = isLockedOut; aspnet_Users.LastLockoutDate = lastLockoutDate; aspnet_Users.FailedPasswordAttemptCount = failedPasswordAttemptCount; aspnet_Users.FailedPasswordAttemptWindowStart = failedPasswordAttemptWindowStart; aspnet_Users.FailedPasswordAnswerAttemptCount = failedPasswordAnswerAttemptCount; aspnet_Users.FailedPasswordAnswerAttemptWindowStart = failedPasswordAnswerAttemptWindowStart; return aspnet_Users; }
/// <summary> /// There are no comments for aspnet_Users in the schema. /// </summary> public void AddToaspnet_Users(aspnet_Users aspnet_Users) { base.AddObject("aspnet_Users", aspnet_Users); }