private static void AddUser() { try { Users e = new Users() { LoginId = "Am12", Password = "******", Role = "admin" }; Users e1 = new Users() { LoginId = "Ra12", Password = "******", Role = "mac" }; UsersBL bl = new UsersBL(); bool aded = bl.Add(e); aded = bl.Add(e1); if (aded) { Console.WriteLine("added succesfully"); } } catch (UniversityException e) { Console.WriteLine(e.Message); } }
static void Main(string[] args) { UsersBL users = new UsersBL(); users.InitList(); users.Add(5, "Николай", "Николаев", "12.04.2001"); }
public ActionResult Edit(int id, FormCollection collection) { try { var editedUser = new User(Convert.ToInt32(collection["Id"]), collection["FirstName"], collection["LastName"], Convert.ToDateTime(collection["DateOfBirth"]), new List <Award>()); for (int i = 5; i < collection.Count; i++) { foreach (Award aw in listOfAwards.GetList()) { if (aw.AwardId == Int32.Parse(collection.AllKeys[i])) { editedUser.Awards.Add(aw); } } } if (editedUser.Id == 0) { listOfUsers.Add(editedUser); } else { listOfUsers.Edit(editedUser); } return(RedirectToAction("Index")); } catch { return(View()); } }
private void CreateUser() { var formUser = new FormUser(_rewardsBL.GetList()); if (formUser.ShowDialog(this) == DialogResult.OK) { _usersBL.Add(new User(formUser.FirstName, formUser.LastName, formUser.DateBirthday, formUser.Rewards)); } }
private void btn_AddUser_Click(object sender, EventArgs e) { var form = new UserForm(); if (form.ShowDialog() == DialogResult.OK) { userBL.Add(form.BirthDate, form.LastName, form.FirstName); DisplayUsers(); } }
private void AddUser() { var form = new UserForm(listOfAwards.GetList()); if (form.ShowDialog() == DialogResult.OK) { listOfUsers.Add(new User(_userId, form.FirstName, form.LastName, form.DateOfBirth, form.ListOfAwards)); DisplayUsers(); } }
private void AddUser() { var form = new UserForm(listOfAwards.GetList()); if (form.ShowDialog() == DialogResult.OK) { listOfUsers.Add(new User(_userId++, form.FirstName, form.LastName, form.DateOfBirth, form.ListOfAwards)); ctrGridUser.DataSource = null; ctrGridUser.DataSource = listOfUsers; } }
public ActionResult Create(UserViewModel userModel) { try { users.Add(userModel.ToUser()); return(RedirectToAction("Index")); } catch { return(View()); } }
public IActionResult AddUser() { string userFirstName = Request.Form["uFirstName"]; string userLastName = Request.Form["uLastName"]; string userBirthday = Request.Form["uBirthday"]; string stringWithRewardsNames = Request.Form["selectRewardsUserCreate"]; string[] userBirthdayParsed = userBirthday.Split("."); var rewardsList = new List <Entites.Reward>(); if (stringWithRewardsNames != null) { string[] rewardsNames = stringWithRewardsNames.Split(","); foreach (var reward in _rewardsBL.GetList()) { foreach (var rewardName in rewardsNames) { if (rewardName == reward.Title) { rewardsList.Add(reward); } } } } _usersBL.Add(new Entites.User(0, userFirstName, userLastName, new DateTime(int.Parse(userBirthdayParsed[2]), int.Parse(userBirthdayParsed[1]), int.Parse(userBirthdayParsed[0])), rewardsList)); return(RedirectToAction("Index")); }