public void ConstructorTest2() { AddNewEmployeeViewModel.Instance.ToString(); NewEmployee pm = AddNewEmployeeViewModel.Instance.NewEmployee(); Assert.DoesNotThrow(() => new AddNewEmployeeViewModel()); }
public JsonResult Update(NewEmployee emp) { var employee = _companyEntities.Entry(emp).State = EntityState.Modified; _companyEntities.SaveChanges(); return(Json(employee, JsonRequestBehavior.AllowGet)); }
public void Execute(object parameter) { Log.Info("Employee saved new employee"); NewEmployee newEmp = AddNewEmployeeViewModel.Instance.NewEmployee(); Employee employee = new Employee(); employee.Username = newEmp.Username; employee.Password = newEmp.Password; employee.Name = newEmp.Name; employee.Surname = newEmp.Surname; employee.StartTime = Parser.Parse(newEmp.StartTime); employee.EndTime = Parser.Parse(newEmp.EndTime); employee.Position = Parser.Parse(newEmp.Position); employee.PasswordUpadateDate = DateTime.Now; employee.Email = newEmp.Email; string username = ClientDialogViewModel.Instance.LogInUser().Username; Log.Debug("proxy poziv - GetHcIdForUser"); int hiringCompanyId = ClientProxy.Instance.GetHcIdForUser(username); Log.Info("Successfully returned id of hiring company"); Log.Debug("proxy poziv - GetHcIdForUser"); employee.HiringCompanyId = ClientProxy.Instance.GetHiringCompany(hiringCompanyId); Log.Info("Successfully returned hiring company"); Log.Debug("proxy poziv - GetHcIdForUser"); bool ret = ClientProxy.Instance.AddEmployee(employee); Log.Info("Successfully added employee"); }
} //close button login private void linkSingup_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { this.Hide(); NewEmployee signUp = new NewEmployee(); signUp.Show(); }
public JsonResult Add(NewEmployee emp) { _companyEntities.NewEmployees.Add(emp); int x = _companyEntities.SaveChanges(); return(Json(x, JsonRequestBehavior.AllowGet)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,FirstName,LastName,Gender,OnTimeCreated,Address,Email,Mobile,UserName,Password,ConfirmPassword,DirectManager,IsDeleted")] NewEmployee newEmployee) { if (id != newEmployee.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(newEmployee); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!NewEmployeeExists(newEmployee.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(newEmployee)); }
public void ShouldSerializeInheritedClassTest() { NewEmployee joe = new NewEmployee(); joe.Name = "Joe Employee"; joe.Age = 100; Employee mike = new Employee(); mike.Name = "Mike Manager"; mike.Manager = mike; joe.Manager = mike; //StringWriter sw = new StringWriter(); //XmlSerializer x = new XmlSerializer(typeof(NewEmployee)); //x.Serialize(sw, joe); //Console.WriteLine(sw); //JavaScriptSerializer s = new JavaScriptSerializer(); //Console.WriteLine(s.Serialize(new {html = @"<script>hi</script>; & ! ^ * ( ) ! @ # $ % ^ ' "" - , . / ; : [ { } ] ; ' - _ = + ? ` ~ \ |"})); string json = JsonConvert.SerializeObject(joe, Formatting.Indented); Assert.AreEqual(@"{ ""Age"": 100, ""Name"": ""Joe Employee"", ""Manager"": { ""Name"": ""Mike Manager"" } }", json); }
public async Task <List <NewEmployee> > GetAllEmployeee() { List <NewEmployee> empList = new List <NewEmployee>(); var emps = await UL.GetAllUser(); if (emps.Count > 0) { foreach (var emp in emps) { NewEmployee em = new NewEmployee { FirstName = emp.FirstName, LastName = emp.LastName, Gender = emp.Gender, OnTimeCreated = emp.dateTime, Address = emp.Address, Email = emp.Email, Mobile = emp.Mobile, UserName = emp.UserName, Password = emp.Password, ConfirmPassword = emp.ConfirmPassword }; empList.Add(em); } } return(empList); }
public async Task <IActionResult> AddNewEmployee(NewEmployee newemployee) { if (HttpContext.Session.GetString("Id") == null) { HttpContext.Session.Clear(); return(RedirectToAction("Index", "Account")); } await newemployee.addEmployee(_context); TempData["name"] = newemployee.Name; TempData["userid"] = newemployee.UserId; TempData["date"] = newemployee.JoiningDate; TempData["password"] = newemployee.Password; TempData["designation"] = newemployee.designation; DateTime a; if (newemployee.JoiningDate < DateTime.Now.Date) { TempData["dateinvalid"] = "true"; return(RedirectToAction("AddEmployee")); } GetUserId newemploye = new GetUserId(_context); int listcount = 0; listcount = newemploye.getuserid(newemployee.UserId.ToString()); if (listcount != 0) { TempData["alreadypresent"] = "true"; return(RedirectToAction("AddEmployee")); } if (newemployee.designation == "shopkeeper") { return(RedirectToAction("SelectBusinessEntity", new { type = 1 })); } else if (newemployee.designation == "warehousemanager") { return(RedirectToAction("SelectBusinessEntity", new { type = 2 })); } else if (newemployee.designation == "stunitmngr" || newemployee.designation == "stunitemployee") { return(RedirectToAction("SelectBusinessEntity", new { type = 3 })); } else if (newemployee.designation == "stunithead") { return(RedirectToAction("stunitdphead", new { type = 3 })); } else { return(RedirectToAction("Index")); } }
private void Add_Click(object sender, RoutedEventArgs e) { var newEmp = new NewEmployee(this); newEmp.Closed += NewEmp_Closed; newEmp.ShowDialog(); }
private void button1_Click(object sender, EventArgs e) { NewEmployee newEmployee = new NewEmployee(); newEmployee.Show(); this.Hide(); }
public ActionResult POST(NewEmployee employee) { var service = new EmployeeService(); service.AddEmployee(employee); return(NoContent()); }
public ActionResult SubmitData(NewEmployee employee) { if (ModelState.IsValid) { return(View()); } return(View("NewIndex")); }
public IHttpActionResult PostMonth(NewEmployee newEmployee) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } return(Ok(db.AddNewUser(newEmployee.FullName, newEmployee.Phone, newEmployee.Email, new PasswordHasher().HashPassword(newEmployee.Password), newEmployee.Category, newEmployee.Exp, Guid.NewGuid().ToString()))); }
public ActionResult CustomValidationIndex(NewEmployee newEmployee) { if (ModelState.IsValid) { ModelState.Clear(); return(View()); } return(View("")); }
private void BtnNewEmp_Click(object sender, EventArgs e) { NewEmployee new_employee = new NewEmployee(); new_employee.TopLevel = false; panelDisplay.Controls.Add(new_employee); new_employee.BringToFront(); new_employee.Show(); }
public void AddEmployee(NewEmployee employee) { DbContext.Add(new sample.DataAccess.Employee { FirstName = employee.FirstName, LastName = employee.LastName }); DbContext.SaveChanges(); }
public void SetupTest() { ne = new NewEmployee() { Name = "Dulo" }; addNewEmployeeViewModelUnderTest.NewEmployee = ne; NewEmployee em = addNewEmployeeViewModelUnderTest.NewEmployee; NewEmployee pm = em; }
public NewEmployee ReadData(SQLiteDataReader reader) { NewEmployee x = new NewEmployee(); x.id = G.ReadI(reader, 0); x.name = G.ReadS(reader, 1); x.isDriver = G.ReadB(reader, 2); x.isSelected = false; return(x); }
public async Task <IActionResult> Create([Bind("Id,FirstName,LastName,Gender,OnTimeCreated,Address,Email,Mobile,UserName,Password,ConfirmPassword,DirectManager,IsDeleted")] NewEmployee newEmployee) { if (ModelState.IsValid) { _context.Add(newEmployee); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(newEmployee)); }
private void button1_Click(object sender, EventArgs e) { var dialog = MessageBox.Show("Are you sure you wan't to add this employee?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dialog == DialogResult.Yes) { emp.Insert(new Employee(txtEmpID.Text, txtFullname.Text, txtPosition.Text)); MessageBox.Show("Employee Added!", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information); NewEmployee?.Invoke(emp); Close(); } }
public bool Add(NewEmployee newEmployee) { using (var db = new SqlConnection(ConnectionString)) { db.Open(); var result = db.Execute(@"INSERT INTO [dbo].[Employee]([FirstName], [LastName], [DepartmentId], [EmployeeTypeId], [AssignedComputer]) VALUES(@FirstName, @LastName, @DepartmentId, @EmployeeTypeId, @AssignedComputer)", newEmployee); return(result == 1); } }
public List <NewEmployee> GetSelectedEmployees(string employees) { List <NewEmployee> xx = new List <NewEmployee>(); if (!string.IsNullOrEmpty(employees)) { string[] employeesList = employees.Split(';'); foreach (var e in employeesList) { NewEmployee x = Get(e); xx.Add(x); } } return(xx); }
public bool UpdateEmployee(int id, NewEmployee newEmployee) { using (var db = new SqlConnection(ConnectionString)) { newEmployee.Id = id; db.Open(); var result = db.Execute(@"UPDATE Employee SET FirstName = @FirstName, LastName = @LastName, DepartmentId = @DepartmentId, EmployeeTypeId = @EmployeeTypeId, AssignedComputer = @AssignedComputer WHERE Id = @id", newEmployee); return(result == 1); } }
public static string CreateUser(NewEmployee Employee, string token) { string jsonString; try { string UrlDomain = ConfigurationManager.AppSettings["AbsorbUrlDomain"]; string Url = UrlDomain + "createabsorbaccount"; HttpWebRequest request = WebRequest.Create(Url) as HttpWebRequest; request.Method = "POST"; request.ContentType = " text/json"; request.Headers.Add("Authorization", token); request.UserAgent = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)"; request.Timeout = 30000; // 30 seconds var javaScriptSerializer = new JavaScriptSerializer(); jsonString = javaScriptSerializer.Serialize(Employee); using (var streamWriter = new StreamWriter(request.GetRequestStream())) { streamWriter.Write(jsonString); streamWriter.Flush(); } // Get response //HttpWebResponse myWebResponse = (HttpWebResponse)request.GetResponse(); HttpWebResponse myWebResponse = GetResponse(request); // Get the response stream using (StreamReader reader = new StreamReader(myWebResponse.GetResponseStream())) { jsonString = reader.ReadToEnd(); }; } catch (Exception e) { Carollo.WriteToLog("Error at AbsorbAPI.CreateUser: "******"System", ActionType.WriteToLogError.ToString(), true, DateTime.Now, ""); throw; } return(jsonString); }
public async Task <Boolean> AddUser(NewEmployee e) { EmpInDAL newemp = new EmpInDAL { FirstName = e.FirstName, LastName = e.LastName, Gender = e.Gender, dateTime = e.OnTimeCreated, Address = e.Address, Email = e.Email, Mobile = e.Mobile, UserName = e.UserName, Password = e.Password, ConfirmPassword = e.ConfirmPassword }; bool result = await UL.CreateNewUser(newemp); return(result); }
public List <NewEmployee> LoadData() { List <NewEmployee> xx = new List <NewEmployee>(); using (SQLiteConnection connection = new SQLiteConnection("Data Source=" + db.GetDataBasePath(G.dataBase))) { connection.Open(); string sql = "SELECT id, name, isDriver FROM employees"; using (SQLiteCommand command = new SQLiteCommand(sql, connection)) { using (SQLiteDataReader reader = command.ExecuteReader()) { while (reader.Read()) { NewEmployee x = ReadData(reader); xx.Add(x); } } } connection.Close(); } return(xx); }
public void TestMethod() { IWebDriver driver = new ChromeDriver(); driver.Url = "C:\\Users\\admin\\Documents\\Training\\html_hw\\index.html"; NewForm NF = new NewForm(driver); NF.IndexAssertion(); NF.addNewForm(); Employee employee = EmployeesCreator.createEmployee(); NewEmployee NE = new NewEmployee(driver); NE.AddNewEmployee(employee); NF.IndexAssertion(); driver.Close(); }
public NewEmployee Get(string id) { NewEmployee x = new NewEmployee(); if (!string.IsNullOrEmpty(id)) { using (SQLiteConnection connection = new SQLiteConnection("Data Source=" + db.GetDataBasePath(G.dataBase))) { connection.Open(); string sql = string.Format("SELECT id, name, isDriver FROM employees WHERE id = {0}", id); using (SQLiteCommand command = new SQLiteCommand(sql, connection)) { using (SQLiteDataReader reader = command.ExecuteReader()) { while (reader.Read()) { x = ReadData(reader); } } } connection.Close(); } } return(x); }
public void ShouldSerializeInheritedClassTest() { NewEmployee joe = new NewEmployee(); joe.Name = "Joe Employee"; joe.Age = 100; Employee mike = new Employee(); mike.Name = "Mike Manager"; mike.Manager = mike; joe.Manager = mike; //StringWriter sw = new StringWriter(); //XmlSerializer x = new XmlSerializer(typeof(NewEmployee)); //x.Serialize(sw, joe); //Console.WriteLine(sw); //JavaScriptSerializer s = new JavaScriptSerializer(); //Console.WriteLine(s.Serialize(new {html = @"<script>hi</script>; & ! ^ * ( ) ! @ # $ % ^ ' "" - , . / ; : [ { } ] ; ' - _ = + ? ` ~ \ |"})); string json = JsonConvert.SerializeObject(joe, Formatting.Indented); StringAssert.AreEqual(@"{ ""Age"": 100, ""Name"": ""Joe Employee"", ""Manager"": { ""Name"": ""Mike Manager"" } }", json); }
public AddNewEmployeeViewModel() { this.SaveNewEmployeeCommand = new SaveNewEmployeeCommand(); this.NewEmployee = new NewEmployee(); }