protected void radgrid_ItemDataBound(object sender, GridItemEventArgs e) { Entities.User u = GetCurrentUser(); u.GetPermissions(); if (u.ChekPermission(Permissions.WaterPointReadOnly.ToString())) { if (e.Item.OwnerTableView.Name == "WP" || e.Item.OwnerTableView.Name == "Service" || e.Item.OwnerTableView.Name == "Event") { if (e.Item is GridDataItem) { GridDataItem dataItem = e.Item as GridDataItem; dataItem["EditCommandColumn"].Visible = false;// Controls[0] as ImageButton).Visible = false; } } } //Задаём ширину для дропдауна в режиме редактирования if (e.Item.OwnerTableView.Name == "Works") { if (e.Item is GridEditableItem && (e.Item as GridEditableItem).IsInEditMode) { GridEditableItem item = (GridEditableItem)e.Item; RadComboBox combo = (RadComboBox)item["WorkType"].Controls[0]; combo.Width = Unit.Pixel(500); } } }
//בודק אם יוזר קיים public static Entities.User CheckIsLogin(Entities.User u) { try { using (DAL.IdialEntities3 DB = new DAL.IdialEntities3()) { DB.Database.Connection.Open(); var user = DB.User.ToList(); var x = user.FirstOrDefault(c => c.UserMail == u.UserMail && c.UserPassword == u.password); if (x == null) { return(null); } DB.Database.Connection.Close(); return(Entities.User.UserEntities(x)); } } catch (Exception e) { BL.SendMail.SendEmail(e.ToString(), e.Message, ""); BL.WriteLogError.WriteLogErrors(e.Message); return(null); } }
public void GivenAUser_WhenThePasswordIsSet_ThenThePasswordIsHashed() { var u = new User(); u.Salt = "wibblefishhatstand"; u.Password = "******"; u.HashedPassword.Should().NotBeNullOrEmpty(); }
public void SaveNewPresentation(PreCreatedPresentation presentation, User user) { if (user == null) { throw new UserHaveNotRulesException(); } if (new UserActions().IsUserExist(user)) { throw new UserNotExistException(); } if (presentation == null) { throw new PresentationNullDataException(); } if (string.IsNullOrEmpty(presentation.Name)) { throw new PresentationWrongNameException(); } try { var createdPresentation = FormNewPresentation(presentation, user.UserId); TrySavePresentation(createdPresentation); } catch (Exception ex) { throw new DataBaseBaseException(ex.Message,ex); } }
// GET public ActionResult User(int id) { var bl = new BusinessLogic(); Entities.User user = bl.GetUserById(id); return(View(user)); }
public UserModel(User user, int rootid) { Name = user.Name; RegDate = user.RegDate; Email = user.Email; RootId = rootid; }
public ActionResult Login(LoginModel model) { Entities.User user = _logic.GetUserByLogin(model.Username); if (ModelState.IsValid) { if (_logic.CheckUser(model.Username, CreatePasswordHash(model.Password))) { if (!user.IsBaned) { FormsAuthentication.SetAuthCookie(model.Username, model.RememberMe); return(RedirectToAction("Index", "Home")); } else { ModelState.AddModelError("", "Учётная запись заблокирована"); } } else { ModelState.AddModelError("", "Неверный логин/пароль/почта не подтверждена"); } } return(View(model)); }
protected void radgrid_InsertCommand(object sender, GridCommandEventArgs e) { GridEditFormInsertItem insertedItem = (GridEditFormInsertItem)e.Item; if (e.Item.OwnerTableView.Name == "Vodomer") { Entities.User u = GetCurrentUser(); dsJournal.InsertParameters.Add(new Parameter("diameter", DbType.Int32, (insertedItem["diameter"].Controls[0] as TextBox).Text)); dsJournal.InsertParameters.Add(new Parameter("Active", DbType.Boolean, (insertedItem["Active"].Controls[0] as CheckBox).Checked.ToString())); dsJournal.InsertParameters.Add(new Parameter("GovRegister", DbType.String, (insertedItem["GovRegister"].Controls[0] as TextBox).Text)); dsJournal.InsertParameters.Add(new Parameter("CheckInterval", DbType.Int32, (insertedItem["CheckInterval"].Controls[0] as TextBox).Text)); dsJournal.InsertParameters.Add(new Parameter("Approve", DbType.Boolean, (insertedItem["Approve"].Controls[0] as CheckBox).Checked.ToString())); dsJournal.InsertParameters.Add(new Parameter("id_seller", DbType.Int32, (insertedItem["sl"].Controls[0] as RadComboBox).SelectedValue)); dsJournal.InsertParameters.Add(new Parameter("DateProduced", DbType.String, (insertedItem["DateProduced"].Controls[0] as TextBox).Text)); dsJournal.InsertParameters.Add(new Parameter("conventional_signth", DbType.String, (insertedItem["conventional_signth"].Controls[0] as TextBox).Text)); dsJournal.InsertParameters.Add(new Parameter("description", DbType.String, (insertedItem["description"].Controls[0] as TextBox).Text)); dsJournal.InsertParameters.Add(new Parameter("gear_ratio", DbType.Double, (insertedItem["gear_ratio"].Controls[0] as TextBox).Text)); /*dsJournal.InsertParameters.Add(new Parameter("WPID", DbType.Int32, (insertedItem["WP"].Controls[0] as RadComboBox).SelectedValue)); * dsJournal.InsertParameters.Add(new Parameter("Rate", DbType.Int32, (insertedItem["Rate"].Controls[0] as TextBox).Text)); * dsJournal.InsertParameters.Add(new Parameter("dateIn", DbType.DateTime, (insertedItem["DateIn"].Controls[0] as RadDatePicker).SelectedDate.ToString())); * dsJournal.InsertParameters.Add(new Parameter("userID", DbType.Int32, u.ID.ToString()));*/ dsJournal.Insert(); //radWM.RadAlert("Показания успешно добавлены.", 300, 200, "", "123"); } e.Item.Edit = false; e.Canceled = true; radgrid.Rebind(); }
/// <summary> /// Create a new friendship between two users. /// NOTE: It does not matter the order of the paramters /// </summary> public void CreateFriendship(User userA, User userB) { if (userA == null || userB == null) throw new Exception("Error creando amistad. Uno de los usuarios no es válido."); dataUsers.AddFriend(userA, userB); }
public Comment(DateTime date, string comment, Publication publication, User author) { Date = date; Value = comment; Publication = publication; Author = author; }
public void InitAccountInfo(Entities.User user, bool remember) { if (user != null) { UserInRolesService uir = new UserInRolesService(); int roleId = uir.GetFirstRoleIdByUser(user.Id); int dayExpries = 1; if (remember) { dayExpries = 365; } CookieHelper.Set(AdminConfigs.COOKIES_USERNAME, user.UserName, dayExpries); CookieHelper.Set(AdminConfigs.COOKIES_AVATAR, user.Avatar, dayExpries); CookieHelper.Set(AdminConfigs.COOKIES_ROLE_ID, roleId.ToString(), dayExpries); CookieHelper.Set(AdminConfigs.COOKIES_USER_ID, user.Id.ToString(), dayExpries); // Kiểm tra tài khoản có phải là Admin không. bool chk = uir.CheckUserIsAdmin(user.Id); string isAdmin = chk ? "1" : "0"; CookieHelper.Set(AdminConfigs.COOKIES_ADMIN, isAdmin, dayExpries); chk = uir.CheckUserIsAgency(user.Id); string isAgency = chk ? "1" : "0"; CookieHelper.Set(AdminConfigs.COOKIES_AGENCY, isAgency, dayExpries); TempData[AdminConfigs.TEMP_USERNAME] = user.UserName; TempData[AdminConfigs.TEMP_USER_ID] = user.Id.ToString(); TempData[AdminConfigs.TEMP_AVATAR] = user.Avatar; } }
public string SignUp(string userFirstName, string userLastName, string userDateOfBirth, string userName, string userPassword, string userTryPassword) { BLLRepository <User> rep_createdUser = new BLLRepository <Entities.User>(); BLLRepository <Login> rep_Login = new BLLRepository <Login>(); Entities.User lastUser = new Entities.User(); try { lastUser = rep_createdUser.List().OrderByDescending(x => x.userCodeID).First(); } catch (Exception) { } try { string userCodeID = getNewArticleCodeID(lastUser.userCodeID, "USER-00000"); rep_createdUser.Insert(new Entities.User { userCodeID = userCodeID, userFirstName = userFirstName, userLastName = userLastName, userDateOfBirth = DateTime.Parse(userDateOfBirth), Articles = new List <Article>(), login = new List <Login>() }); rep_Login.Insert(new Entities.Login { loginUserNameID = userName, loginUserPassword = userPassword, user = rep_createdUser.Find(x => x.userCodeID == userCodeID) }); return("success"); } catch (Exception) { return("error"); } }
protected void Page_Load(object sender, EventArgs e) { user = muro.LoadLoggedUser(this); Publication p = GetPublication(); if (p != null) { string pictureFile = CtrMuro.GetPublicationPictureFile(p); // Check if the file could be loaded without issues if (pictureFile != null) { this.picture.ImageUrl = pictureFile; } else { index.DisplayMessage("La imagen de la publicación no ha podido ser cargada.", this); Response.Redirect("index.aspx"); } } else // There was an error loading the publication { index.DisplayMessage("La publicación no ha podido ser cargada.", this); Response.Redirect("index.aspx"); } }
public void AddLending(LibraryItem item, User user, DateTime lendingDate) { var lendingDetails = new LendingDetails(item, user, lendingDate); this.lendings.Add(lendingDetails); user.AddLending(lendingDetails); }
public static Entities.User registerUser(Entities.User user) { try { using (DAL.IdialEntities3 DB = new DAL.IdialEntities3()) { DB.Database.Connection.Open(); DB.User.Add(Entities.User.UserDAL(user)); DB.SaveChanges(); var u = DB.User.FirstOrDefault(x => x.UserMail == user.UserMail && x.UserPassword == user.password); //BL.SendMail.SendEmail(data, "ברוך בואך לאתר אידיאל", u.UserMail); //var p = BL.SendMail.register(u.UserName, u.UserPassword, u.UserMail); return(Entities.User.UserEntities(u)); } } catch (Exception e) { BL.SendMail.SendEmail(e.ToString(), e.Message, ""); BL.WriteLogError.WriteLogErrors(e.Message); return(null); } }
/// <summary> /// Saves or updates a user /// </summary> /// <param name="user">A user</param> public void SaveOrUpdate(User user) { if (user == null) { throw new ArgumentNullException("user"); } this.Session.SaveOrUpdate(user); }
public static Story Story(Project project, StoryPoint storyPoints, int hoursPerStoryPoint, Priority moscowPrio, User aangemaaktDoor) { Story story = new Story(project, aangemaaktDoor, Impact.Normal, StoryType.UserStory); story.StoryPoints = storyPoints; story.Estimation = new TimeSpan(story.StoryPointsValue*hoursPerStoryPoint); story.ProductBacklogPriority = moscowPrio; return story; }
public frmChatWindow() { InitializeComponent(); com = new UDPComm(); Me = new Entities.User(Entities.Properties.Settings.Default.DisplayName, (UserStatus)Entities.Properties.Settings.Default.Status, com.GetMyIPAddress()); com.TextMessageRecieved += Com_MessageRecieved; com.Start(); }
public UserViewModel(User entityUser) { BlogTitle = entityUser.BlogTitle; IsAuthenticated = true; Email = entityUser.Email; Name = entityUser.Name; BlogSubTitle = entityUser.BlogDescription; }
public User(Entities.User user) { this.Email = user.Email; this.FullName = user.FullName; this.Password = user.Password; this.Salt = user.Salt; this.Role = user.Role; }
public void GivenAUser_WhenTheHashedPasswordIsSetInTheConstructor_ThenTheSamePasswordIsSetInThePasswordAccessor() { var u = new User("email", "password"); var hashedPassword = u.HashedPassword; u.Password = "******"; hashedPassword.Should().Be(u.HashedPassword); }
public static User Parse(UserViewModel viewModel) { User user = new User(); user.Email = viewModel.Email; user.Password = viewModel.Password; return user; }
public void GivenAUser_WhenTheHashedPasswordIsSetInTheConstructor_AndADifferentPasswordIsSetInThePasswordAccessor_ThenThePasswordsAreDifferent() { var u = new User("email", "password"); var hashedPassword = u.HashedPassword; u.Password = "******"; hashedPassword.Should().NotBe(u.HashedPassword); }
private void EnterPassword(Entities.User user) { Thread.Sleep(1000); password.Get().Clear(); password.Get().SendKeys(user.Password); password.Get().Submit(); Thread.Sleep(10000); }
/// <summary> /// Create a new publication /// </summary> /// <param name="value">The content is pure plain text</param> /// <param name="date">The date when it was written</param> /// <param name="user">The author that have written the publication</param> /// <param name="picture">The picture of the publication</param> public Publication(string value, DateTime date, User user, string picture) { this.Value = value; this.Date = date; this.Author = user; this.Picture = picture; this.Comments= null; }
protected void btnRegister_Click(object sender, EventArgs e) { //Create a new user User user = new User(txtName.Text, txtPassword.Text, txtEmail.Text, "user"); //Register the user and return a result message lblResult.Text = ConnectionClass.RegisterUser(user); }
public static Story StoryMetSprintStoryEnSprintBacklogPrioriteit(User gebruiker, Priority prioriteit, Sprint sprint) { Story story = Story(gebruiker); sprint.CreateSprintStoryFor(story); story.SprintStories[0].SprintBacklogPriority = prioriteit; return story; }
public override void SetUp() { project = new Project(); sprint = new Sprint(); gebruiker = new User(); project.AddSprint(sprint); base.SetUp(); }
protected void radgrid_ItemCreated(object sender, GridItemEventArgs e) { Entities.User u = GetCurrentUser(); u.GetPermissions(); if (u.ChekPermission(Permissions.WaterPointReadOnly.ToString())) { e.Item.OwnerTableView.CommandItemDisplay = GridCommandItemDisplay.None; } }
public void TestVindSprintGebruikerVanGebruikerVoorSprint() { User gb = new User(); sprint.AddUser(gb, SprintRole.Developer); SprintUser sg = gb.GetSprintUserFor(sprint); Assert.AreEqual(gb, sg.User); }
public void TestGeefActieveSprintGebruikerVanGebruikerTerwijlDezeNogNietGezetIs() { User gb = new User(); sprint.AddUser(gb, SprintRole.Developer); SprintUser sg = gb.GetActiveSprintUser(); Assert.AreEqual(null, sg); }
public frmChatWindow(StatusIndicator si) { InitializeComponent(); SI = si; Me = new Entities.User(); com = new UDPComm(); com.TextMessageRecieved += Com_MessageRecieved; com.Start(); }
public override void SetUp() { gebruiker = new User(); sprintGebruiker = Creation.SprintGebruiker(gebruiker); taak = new Task(); taak2 = new Task(); base.SetUp(); }
public void TestGeefActieveSprintGebruikerVanGebruiker() { User gb = new User(); gb.ActiveSprint = sprint; sprint.AddUser(gb, SprintRole.Developer); SprintUser sg = gb.GetActiveSprintUser(); Assert.AreEqual(sg.User, gb); }
public void Registration(User user) { User u = _uow.Users.GetFirst(us => us.Email == user.Email); if (u != null) throw new Exception("the user exists"); _uow.Users.Create(user); _uow.Commit(); }
public ActionResult AddTopic(TopicModel model) { Entities.User user = _ulogic.GetUserByLogin(User.Identity.Name); if (ModelState.IsValid) { _logic.AddTopic(_sectionId, user.Id, model.TopicName, model.Text); return(RedirectToAction("Section", "Forum", new { id = _sectionId, sectionName = _sectionName })); } return(View(model)); }
public void TestVindGeenSprintGebruikerVanAndereSprints() { User gb = new User(); Sprint sprint2 = new Sprint(); sprint2.AddUser(gb, SprintRole.Developer); sprint.AddUser(gb, SprintRole.Developer); SprintUser sg = gb.GetSprintUserFor(sprint); Assert.AreEqual(sprint, sg.Sprint); }
public Entities.User ToEntity() { Entities.User entity = new Entities.User { Email = Email, FullName = FullName, Password = Password, Salt = Salt, Role = Role }; return(entity); }
private void SingIn_Load(object sender, EventArgs e) { user = new Entities.User(); if (Edit) { EditUser(); if (UserLogged.Instance.user.TYPE == 0) { cbType.Enabled = true; } } }
public User Add(User user) { const string sqlQuery = "INSERT INTO [User] (FirstName, LastName, UserName) " + "VALUES (@" + "FirstName, @LastName, @UserName)"+ "SELECT Id FROM [User] WHERE Id = scope_identity()"; if (user == null) return null; var userId = _dbConnection.QueryWithRetry<User>(sqlQuery, new {user.FirstName, user.LastName, user.UserName}).First(); user.Id = userId.Id; return user; }
public Entities.User register([FromBody] Entities.User user) { bool x = BL.UserLogic.NotValidPasswordUser(user.UserMail); if (x == true) { return(BL.UserLogic.registerUser(user)); } else { return(null); } }
public ActionResult Login(Entities.User user, string ReturnUrl) { if (IsValid(user)) { GetIdByLogin(user.Name); FormsAuthentication.SetAuthCookie(GetIdByLogin(user.Name).ToString(), false); return(Redirect(ReturnUrl)); } else { return(View(user)); } }
/// <summary> /// Create a new comment and store it. /// </summary> /// <param name="value">Value of the comment</param> /// <param name="date">Date when the comment was written</param> /// <param name="author">Author who wrote the comment</param> /// <param name="publication">Publication where the comment belongs</param> public void CreateComment(string value, DateTime date, User author, Publication publication) { if (!ValidContent(value)) throw new Exception("El contenido no puede estar vacio ni ser mayor a 500 caracteres."); if (publication == null) throw new Exception("La publicación no es válida."); Comment comment = new Comment(date, value, publication, author); // Store the new comment dataPublications.AddComment(publication, comment); }
public FileEntity(string name, User owner, string ext, int size, DateTime upldate, int downloads, string fullname, AccessType access, string contenttype) { Name = name; Owner = owner; Extension = ext; Size = size; UploadDate = upldate; Downloads = downloads; FullName = fullname; Access = access; ContentType = contenttype; }
protected void Page_Load(object sender, EventArgs e) { user = uLogic.GetLoggedUser(); if (Request["admin"] != "true" && (user) == null) { return; } if (!int.TryParse(Request["orderid"], out orderid)) { return; } LoadOrder(); }
private bool IsValid(Entities.User user) { var bl = new BusinessLogic(); if (TryValidateModel(user) && bl.LogIn(user) != null) { return(true); } else { ViewBag.WrongPassword = "******"; return(false); } }
public static void Add(User u) { var query = from e in collection.AsQueryable<User>() where e.Email == u.Email select e; if (query.Count() != 0) { throw new Exception("Jest juz konto z tym adresem email!"); } else { collection.Insert(u); } }
public ActionResult AddComment(CommentModel model) { Entities.User user = _ulogic.GetUserByLogin(User.Identity.Name); if (ModelState.IsValid) { _logic.AddComment(_topicId, _topicName, user.Id, model.Text); return(RedirectToAction("Topic", "Forum", new { id = _topicId })); } else { ModelState.AddModelError("", "Заполните поле"); } //return RedirectToAction("Topic", "Forum", new { id = _topicId }); return(PartialView("_AddCommentPartial", model)); }
public ActionResult Profile(string userName) { ViewBag.IsAdmin = IsAdmin(); ViewBag.IsSuperAdmin = IsSuperAdmin(); Entities.User user = _logic.GetUserByLogin(userName); if (user != null) { ViewBag.Time = _flogic.GetUserTime(user.Id); return(View(_logic.GetUser(user.Id))); } else { return(new HttpStatusCodeResult(404, "User Not Found")); } }
public bool IsSuperAdmin() { Entities.User user = _logic.GetUserByLogin(User.Identity.Name); if (user == null) { return(false); } else if (user.Role == "superAdmin") { return(true); } else { return(false); } }
public bool Get(string user) { User toPass = new Entities.User { Email = user }; Dictionary <Expression <Func <User, object> >, Func <User, object> > Filters = new Dictionary <Expression <Func <User, object> >, Func <User, object> >(); Filters.Add(c => c.Email, c => c.Email); List <User> us = DatabaseHandler <User> .getDocumentContent(toPass, Filters); if (us.Count == 1) { return(true); } return(false); }
/// <summary> /// Метод AddUser создаёт нового пользователя в базе данных /// </summary> /// <param name="user"></param> /// <returns></returns> public bool AddUser(User user) { if (CheckName(user.Name)) throw new ArgumentException("Такой логин уже занят.", "Name"); if (CheckEmail(user.Email)) throw new ArgumentException("Пользователь с таким e-mail уже зарегистрирован.", "Email"); bool result = true; using (SqlConnection connection = new SqlConnection(ConnectionString)) { SqlCommand command = new SqlCommand("INSERT INTO MegaFileStorage.Users (UserName, Pass, RegistrationDate, " + "UserType, Email) VALUES(@un, @p, @rd, @ut, @e)"); command.Connection = connection; command.Parameters.AddWithValue("@un", user.Name); command.Parameters.AddWithValue("@p", user.Password); command.Parameters.AddWithValue("@rd", user.RegDate); command.Parameters.AddWithValue("@ut", user.Type); command.Parameters.AddWithValue("@e", user.Email); connection.Open(); result &= command.ExecuteNonQuery() == 1; } user = GetUserByName(user.Name); using (SqlConnection connection = new SqlConnection(ConnectionString)) { SqlCommand command = new SqlCommand("INSERT INTO MegaFileStorage.Files (OwnerID, FileName, Extension," + " UploadDate, FullName, AccessType, Size) VALUES(@oid, @n, @e, @ud, @fn, @at, @s)"); command.Connection = connection; command.Parameters.AddWithValue("@oid", user.ID); command.Parameters.AddWithValue("@n", user.Name); command.Parameters.AddWithValue("@e", "folder"); command.Parameters.AddWithValue("@ud", DateTime.Now); command.Parameters.AddWithValue("@fn", user.Name); command.Parameters.AddWithValue("@at", 0); command.Parameters.AddWithValue("@s", 0); connection.Open(); result &= command.ExecuteNonQuery() == 1; } result &= CreateSubFolder(GetFileByFullName(user.Name), "root"); return result; }
public User Get(string user, string pass) { User toPass = new Entities.User { Email = user, Password = pass }; Dictionary <Expression <Func <User, object> >, Func <User, object> > Filters = new Dictionary <Expression <Func <User, object> >, Func <User, object> >(); Filters.Add(c => c.Email, c => c.Email); Filters.Add(c => c.Password, c => c.Password); List <User> us = DatabaseHandler <User> .getDocumentContent(toPass, Filters); if (us.Count == 1) { return(us[0]); } return(new User()); }
protected void Page_Load(object sender, EventArgs e) { user = muro.LoadLoggedUser(this); externalUserVisited = (User)Session["UserVisited"]; btnGoHome.Click += btnGoHome_Click; btnLogout.Click += btnLogout_Click; timer1.Tick += timer1_Tick; btnSendMessage.Click += btnSendMessage_Click; LoadInfoForUser(user); if (!IsPostBack) { RefreshMessages(); } }
protected void radgrid_InsertCommand(object sender, GridCommandEventArgs e) { GridEditFormInsertItem insertedItem = (GridEditFormInsertItem)e.Item; if (e.Item.OwnerTableView.Name == "Employees") { Entities.User u = GetCurrentUser(); //dsJournal.InsertParameters.Add(new Parameter("RegNumber", DbType.String, (insertedItem["RegNumber"].Controls[0] as TextBox).Text)); //dsJournal.InsertParameters.Add(new Parameter("Correspondent", DbType.String, (insertedItem["Correspondent"].Controls[0] as TextBox).Text)); //dsJournal.InsertParameters.Add(new Parameter("Address", DbType.String, (insertedItem["Address"].Controls[0] as TextBox).Text)); //dsJournal.InsertParameters.Add(new Parameter("RegNumberJuridical", DbType.String, (insertedItem["RegNumberJuridical"].Controls[0] as TextBox).Text)); //dsJournal.InsertParameters.Add(new Parameter("DateJuridical", DbType.DateTime, (insertedItem["date_juridical"].Controls[0] as RadDatePicker).SelectedDate.ToString())); //dsJournal.InsertParameters.Add(new Parameter("CodeFrom", DbType.String, (insertedItem["CodeFrom"].Controls[0] as TextBox).Text)); //dsJournal.InsertParameters.Add(new Parameter("PlaneDate", DbType.DateTime, (insertedItem["date_plane"].Controls[0] as RadDatePicker).SelectedDate.ToString())); //dsJournal.InsertParameters.Add(new Parameter("DateExecution", DbType.DateTime, (insertedItem["date_exec"].Controls[0] as RadDatePicker).SelectedDate.ToString())); //dsJournal.InsertParameters.Add(new Parameter("TypeLetter", DbType.String, (insertedItem["TypeLetter"].Controls[0] as TextBox).Text)); //dsJournal.InsertParameters.Add(new Parameter("TextResolution", DbType.String, (insertedItem["TextResolution"].Controls[0] as TextBox).Text)); //dsJournal.InsertParameters.Add(new Parameter("DateView", DbType.DateTime, (insertedItem["date_view"].Controls[0] as RadDatePicker).SelectedDate.ToString())); //dsJournal.InsertParameters.Add(new Parameter("Viewer", DbType.String, (insertedItem["Viewer"].Controls[0] as TextBox).Text)); //dsJournal.InsertParameters.Add(new Parameter("RegNumberOut", DbType.String, (insertedItem["RegNumberOut"].Controls[0] as TextBox).Text)); //dsJournal.InsertParameters.Add(new Parameter("TypeMail", DbType.String, (insertedItem["TypeMail"].Controls[0] as TextBox).Text)); //dsJournal.InsertParameters.Add(new Parameter("Comment", DbType.String, (insertedItem["Comment"].Controls[0] as TextBox).Text)); //dsJournal.InsertParameters.Add(new Parameter("ResponsibleContractorID", DbType.Int32, (insertedItem["rc"].Controls[0] as RadComboBox).SelectedValue)); dsJournal.InsertParameters.Add(new Parameter("name", DbType.String, (insertedItem["name"].Controls[0] as TextBox).Text)); dsJournal.InsertParameters.Add(new Parameter("sex", DbType.String, (insertedItem["sex"].Controls[0] as TextBox).Text)); //dsJournal.InsertParameters.Add(new Parameter("name", DbType.String, (insertedItem["name"].Controls[0] as TextBox).Text)); dsJournal.InsertParameters.Add(new Parameter("position", DbType.String, (insertedItem["position"].Controls[0] as TextBox).Text)); dsJournal.InsertParameters.Add(new Parameter("phone", DbType.String, (insertedItem["phone"].Controls[0] as TextBox).Text)); dsJournal.InsertParameters.Add(new Parameter("growth", DbType.String, (insertedItem["growth"].Controls[0] as TextBox).Text)); dsJournal.InsertParameters.Add(new Parameter("birthday", DbType.DateTime, (insertedItem["birthday"].Controls[0] as RadDatePicker).SelectedDate.ToString())); dsJournal.InsertParameters.Add(new Parameter("Address", DbType.String, (insertedItem["Address"].Controls[0] as TextBox).Text)); dsJournal.Insert(); } e.Item.Edit = false; e.Canceled = true; radgrid.Rebind(); }
public Entities.UserCollection GetAll() { Entities.UserCollection users = new Entities.UserCollection(); using (SqlConnection cnn = new SqlConnection(ConnectionString)) { string query = "SELECT * FROM Users"; using (SqlCommand cmd = new SqlCommand(query, cnn)) { cmd.CommandType = CommandType.Text; cnn.Open(); using (SqlDataReader reader = cmd.ExecuteReader()) { if (reader != null && reader.HasRows) { ICrypt crypto = new SimpleCrypt(); while (reader.Read()) { Entities.User user = new Entities.User(); user.Id = Utils.GetSafeInt32(reader, "UserId"); user.Name = crypto.Decrypt(Utils.GetSafeString(reader, "UserName")); user.Password = crypto.Decrypt(Utils.GetSafeString(reader, "UserPass")); user.Culture = cultures[Utils.GetSafeString(reader, "UserLocale")]; user.IsEnabled = Utils.GetSafeBoolean(reader, "IsEnabled"); user.Role = Membership.Roles.GetById(Utils.GetSafeInt32(reader, "RoleId")); user.IsEmployee = Utils.GetSafeBoolean(reader, "IsEmployee"); Membership.UserSettings.LoadById(user); users.Add(user); } } } } } return(users); }
public string sendArticle(string title, string articlecontent, string loginUserCode, string categoryCode) { try { BLLRepository <User> rep_user = new BLLRepository <Entities.User>(); BLLRepository <Categories> rep_ctg = new BLLRepository <Entities.Categories>(); BLLRepository <Article> rep_artc = new BLLRepository <Entities.Article>(); Entities.User user = rep_user.Find(x => x.userCodeID == loginUserCode); Entities.Categories ctg = rep_ctg.Find(x => x.categoryCode == categoryCode); Article lastArticle = null; string LastArticleCodeID = ""; try { lastArticle = rep_artc.List().OrderByDescending(x => x.articleCodeID).First(); LastArticleCodeID = lastArticle.articleCodeID; } catch (Exception) { } string ArticleCodeID; ArticleCodeID = getNewArticleCodeID(LastArticleCodeID, "ARTC-00000"); int insertCount = rep_artc.Insert(new Entities.Article { articleCodeID = ArticleCodeID, articleContent = articlecontent, articleSharedDate = DateTime.Now, articleTitle = title, category = ctg, user = user, comments = new List <ArticleComment>(), likes = new List <ArticleLikes>() }); //BLLRepository<ArticleComment> rep_artCommt = new BLLRepository<Entities.ArticleComment>(); //BLLRepository<ArticleLikes> rep_artLike = new BLLRepository<Entities.ArticleLikes>(); //rep_artCommt.Insert() return("success"); } catch (Exception) { return("error"); } }
protected void radgrid_InsertCommand(object sender, GridCommandEventArgs e) { GridEditFormInsertItem insertedItem = (GridEditFormInsertItem)e.Item; if (e.Item.OwnerTableView.Name == "Dossier") { Entities.User u = GetCurrentUser(); dsJournal.InsertParameters.Add(new Parameter("employee_id", DbType.Int32, (insertedItem["ep"].Controls[0] as RadComboBox).SelectedValue)); dsJournal.InsertParameters.Add(new Parameter("comment", DbType.String, (insertedItem["comment"].Controls[0] as TextBox).Text)); dsJournal.InsertParameters.Add(new Parameter("projects", DbType.String, (insertedItem["projects"].Controls[0] as TextBox).Text)); dsJournal.Insert(); } e.Item.Edit = false; e.Canceled = true; radgrid.Rebind(); }
public static bool Authenticate(Entities.User user) { foreach (User item in users) { if (string.Equals(item.Name, user.Name, StringComparison.InvariantCulture) && item.Password == user.Password) { if (item.IsEnabled) { item.IsAuthenticated = true; DomainModel.Application.User = item; user.Copy(item); //user.IsAuthenticated = true; } break; } } return(user.IsAuthenticated); }
public string setLike(string userCode, string articleCode, bool like) { try { BLLRepository <User> rep_user = new BLLRepository <User>(); BLLRepository <Article> rep_article = new BLLRepository <Article>(); Entities.User user = rep_user.Find(x => x.userCodeID == userCode); Entities.Article article = rep_article.Find(x => x.articleCodeID == articleCode); if (like) //Like işlemi yapılacak { BLLRepository <ArticleLikes> rep_artLike = new BLLRepository <ArticleLikes>(); rep_artLike.Insert(new ArticleLikes { article = article, user = user }); return("liked"); } else // Unlike işlemi yapılacak { BLLRepository <ArticleLikes> rep_artLike = new BLLRepository <ArticleLikes>(); ArticleLikes articlelike = new ArticleLikes(); List <ArticleLikes> artLikeLİst = rep_artLike.List(); try { articlelike = rep_artLike.List(x => x.article.articleCodeID == article.articleCodeID & x.user.userCodeID == user.userCodeID).First(); } catch (Exception) { } if (articlelike.articleLikesID != null) // like kaydı bulunmuş ise { rep_artLike.Remove(articlelike); } return("unliked"); } } catch (Exception) { return("error"); } }