示例#1
0
        public void CasualEmployeeChanges()
        {
            //Arrange
            CasualEmployee em = new CasualEmployee
            {
                FirstName   = "First Name Test",
                LastName    = "Last Name Test",
                Email       = "*****@*****.**",
                Role        = "Role Level 1",
                RatePerHour = 2,
            };

            //Act
            em.FirstName   = "First Name Test";
            em.LastName    = "Last Name Test";
            em.Email       = "*****@*****.**";
            em.Role        = "Role Level 2";
            em.RatePerHour = 1;
            //Assert
            Assert.Equal("First Name Test", em.FirstName);
            Assert.Equal("Last Name Test", em.LastName);
            Assert.Equal("*****@*****.**", em.Email);
            Assert.Equal("Role Level 2", em.Role);
            Assert.Equal(1, em.RatePerHour);
        }
示例#2
0
        public CasualEmployee DeleteCasual(int id)
        {
            CasualEmployee employee = context.CasualEmployees.FirstOrDefault(em => em.Id == id);

            context.CasualEmployees.Remove(employee);
            context.SaveChanges();
            return(employee);
        }
        public IActionResult DeleteCasual(int id)
        {
            CasualEmployee em = casualRepo.DeleteCasual(id);

            if (em != null)
            {
                TempData["message"] = $"{em.FirstName} was deleted";
            }
            return(RedirectToAction(nameof(Index)));
        }
        public IActionResult DoTask(CasualEmployee casual)
        {
            CasualEmployee ca = casualRepo.GetAllCasual().FirstOrDefault(c => c.FirstName == casual.FirstName);

            if (ca != null)
            {
                var result = task.Action1(ca.FirstName, ca.LastName);
                savedTask.SavedTaskResult($"{result} with Employment Level: {ca.Role}");
                return(View(nameof(Result), $"{result} with Employment Level: {ca.Role}"));
            }
            return(View(casual));
        }
 public IActionResult EditEmployee(CasualEmployee employee)
 {
     if (ModelState.IsValid)
     {
         casualRepo.EditEmployee(employee);
         //Using Temp Data for Redirection to EmployeeAction Method
         TempData["Message"] = $"{employee.LastName} has been saved!";
         return(RedirectToAction(nameof(Index)));
     }
     else
     {
         // there is something wrong with the data values
         return(View(employee));
     }
 }
 public IActionResult CreateEmployee(CasualEmployee employee)
 {
     if (ModelState.IsValid)
     {
         var em = casualRepo.GetAllCasual().FirstOrDefault(m => m.Email == employee.Email);
         if (em == null)
         {
             casualRepo.CreateCasual(employee);
             return(RedirectToAction(nameof(Index)));
         }
         else
         {
             return(View(nameof(Record), $"User: {employee.FirstName} {employee.LastName} with Email: {employee.Email} already exist!"));
         }
     }
     return(View(employee));
 }
示例#7
0
 public CasualEmployee EditEmployee(CasualEmployee employee)
 {
     context.CasualEmployees.Update(employee);
     context.SaveChanges();
     return(employee);
 }
示例#8
0
 public void CreateCasual(CasualEmployee casual)
 {
     context.Add(casual);
     context.SaveChanges();
 }
示例#9
0
 public void addCasualEmployee(CasualEmployee casualEmployee)
 {
     employees.Add(casualEmployee);
 }
        public IActionResult Edit(CasualEmployee employee)
        {
            CasualEmployee em = casualRepo.GetAllCasual().FirstOrDefault(em => em.Id == employee.Id);

            return(View(em));
        }
 public IActionResult Create(CasualEmployee employee)
 {
     return(View(employee));
 }