public int Upsert(Entity.Employee employee)
 {
     if (employee.Id == Guid.Empty)
     {
         return(_empRepository.Add(employee));
     }
     return(_empRepository.Update(employee));
 }
Exemple #2
0
        public IActionResult Create(EmployeeCreateViewModel emp)
        {
            if (ModelState.IsValid)
            {
                string uniqueFilename = ProcessPhoto(emp);
                //CreateViewModel --> Website.Model.Employee
                var newEmployee = new Employee
                {
                    Name       = emp.Name,
                    Email      = emp.Email,
                    Department = emp.Department,
                    PhotoPath  = uniqueFilename
                };
                //Website.Model.Employee--> DataAccess.Repository.EmployeeModel
                var employeeModel = new EmployeeModel
                {
                    Name       = newEmployee.Name,
                    EmailId    = newEmployee.Email,
                    Department = (EmployeeManagement.DataAccess.Dept)newEmployee.Department,
                    PhotoPath  = newEmployee.PhotoPath // Added this here
                };
                EmployeeModel newEmpployee = _empRepository.Add(employeeModel);

                // DataAccess.Repository.EmployeeModel--> Website.Model.Employee
                Employee employee = new Employee
                {
                    Id         = newEmpployee.Id,
                    Name       = newEmpployee.Name,
                    Email      = newEmpployee.EmailId,
                    Department = (KudVenvat1.Models.Dept)newEmpployee.Department,
                    PhotoPath  = newEmpployee.PhotoPath // Added this here
                };

                return(RedirectToAction("Details", new { id = newEmpployee.Id }));
            }
            else
            {
                return(View());
            }
        }
Exemple #3
0
 public string PostEmp(Emp item)
 {
     item = repository.Add(item);
     return("added sucessfully");
 }