bool IIssuesDAC.DeleteIssue(int issueId)
        {
            bool retVal = false;

            try
            {
                using (EmployeePortalEntities context = new EmployeePortalEntities())
                {
                    var deleteIssue = context.Issues.First(item => item.IssueId == issueId);
                    if (deleteIssue != null)
                    {
                        deleteIssue.IsActive = false;
                        context.SaveChanges();
                        retVal = true;
                    }
                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                ExceptionManager.HandleException(ex);
                throw new DACException(ex.Message);
            }
            return(retVal);
        }
        public ActionResult Create([Bind(Include = "Id,Name,JobDesc,Number,Department,HourlyPay,Bonus,EmployeeTypeId")] Employee employee)
        {
            if (ModelState.IsValid)
            {
                //EmployeeManagerFactory empFactory = new EmployeeManagerFactory();
                //IEmployeeManager empManager = empFactory.GetEmployeeManager(employee.EmployeeTypeId);
                //if (empManager != null)
                //{
                //    employee.Bonus = empManager.GetBonus();
                //    employee.HourlyPay = empManager.GetHourlyPay();
                //}

                BaseEmployeeFactory employeeFactory = new EmployeeManagerFactory().CreateFactory(employee);
                employeeFactory.ApplySalary();

                IComputerFactory      computerFactory = new EmployeeSystemFactory().Create(employee);
                EmployeeSystemManager manager         = new EmployeeSystemManager(computerFactory);
                employee.ComputerDetails = manager.GetSystemDetails();

                db.Employees.Add(employee);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.EmployeeTypeId = new SelectList(db.EmployeeTypes, "Id", "Types", employee.EmployeeTypeId);
            return(View(employee));
        }
        public async Task <IHttpActionResult> CreateMessage(int userId, [FromBody] MessageForCreationDto messageForCreationDto)
        {
            var sender = await _repo.GetUser(userId);

            var currentUserId = int.Parse(ClaimsPrincipal.Current.Claims.First(c => c.Type == ClaimTypes.NameIdentifier).Value);

            var userFromRepo = await _repo.GetUser(currentUserId);

            userFromRepo.LastActive      = DateTime.Now;
            db.Entry(userFromRepo).State = EntityState.Modified;           // data is updated in database
            await db.SaveChangesAsync();

            messageForCreationDto.SenderId = userId;

            var recipient = await _repo.GetUser(messageForCreationDto.RecipientId);

            if (recipient == null)
            {
                return(BadRequest("Could not find user"));
            }

            var message = Mapper.Map <Message>(messageForCreationDto);

            db.Messages.Add(message);

            db.SaveChanges();

            var messageToReturn = Mapper.Map <MessageToReturnDto>(message);

            return(CreatedAtRoute("GetMessage", new { userId, id = message.Id }, messageToReturn));
        }
        public ActionResult BuildSystem(int employeeID, string RAM, string HDDSize)
        {
            Employee       employee       = db.Employees.Find(employeeID);
            ComputerSystem computerSystem = new ComputerSystem(RAM, HDDSize);

            employee.SystemConfigurationDetails = computerSystem.Build();
            db.Entry(employee).State            = EntityState.Modified;
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemple #5
0
        public ActionResult Create([Bind(Include = "Id,Name,JobDescription,Number,Department")] Employee employee)
        {
            if (ModelState.IsValid)
            {
                db.Employees.Add(employee);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(employee));
        }
Exemple #6
0
        public ActionResult Create([Bind(Include = "ID,Name,SeniorManagerID,Active")] Manager manager)
        {
            if (ModelState.IsValid)
            {
                db.Managers.Add(manager);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.SeniorManagerID = new SelectList(db.Managers, "ID", "Name", manager.SeniorManagerID);
            return(View(manager));
        }
        public ActionResult Create([Bind(Include = "ID,Name,ManagerID,Active")] Employee employee)
        {
            if (ModelState.IsValid)
            {
                db.Employees.Add(employee);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ManagerID = new SelectList(db.Managers, "ID", "Name", employee.ManagerID);
            return(View(employee));
        }
Exemple #8
0
        public EmployeeDto UpdateEmployee(int id, EmployeeDto employee)
        {
            var employeEntity = _dbContext.Employees.FirstOrDefault(x => x.ID == id);

            if (employeEntity == null)
            {
                throw new ArgumentNullException($"Employee Id - {id} couldn't be found!");
            }
            employeEntity.Name      = employee.Name;
            employeEntity.ManagerID = employee.ManagerID;
            _dbContext.Employees.AddOrUpdate(employeEntity);
            _dbContext.SaveChanges();
            return(Mapper.Map <Data.Employee, EmployeeDto>(employeEntity));
        }
Exemple #9
0
        public void UpdateManager(int id, ManagerDto manager)
        {
            var managerEntity = _dbContext.Managers.Find(id);

            if (managerEntity == null)
            {
                throw new NullReferenceException();
            }

            var updatedMangerEntity = Mapper.Map <ManagerDto, Data.Manager>(manager);

            _dbContext.Managers.AddOrUpdate(updatedMangerEntity);
            _dbContext.SaveChanges();
        }
Exemple #10
0
 public HttpResponseMessage Put(int id, [FromBody] Employee employee)
 {
     try
     {
         using (EmployeePortalEntities entities = new EmployeePortalEntities())
         {
             var entity = entities.Employees.FirstOrDefault(x => x.Id == id);
             if (entity == null)
             {
                 return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Employee with id:" + id.ToString() + " not found to update"));
             }
             else
             {
                 entity.FirstName = employee.FirstName;
                 entity.LastName  = employee.LastName;
                 entity.Gender    = employee.Gender;
                 entity.Salary    = employee.Salary;
                 entities.SaveChanges();
                 return(Request.CreateResponse(HttpStatusCode.OK, entity));
             }
         }
     }
     catch (Exception ex)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
     }
 }
Exemple #11
0
        public IUsersDTO CreateUser(IUsersDTO usersDTO)
        {
            IUsersDTO createUserRetval = null;

            try
            {
                using (EmployeePortalEntities context = new EmployeePortalEntities())
                {
                    Employee employee = new Employee();
                    EntityConverter.FillEntityFromDTO(usersDTO.Employee, employee);
                    context.Employees.Add(employee);

                    User user = new User();
                    user.EmployeeId = employee.EmployeeId;
                    EntityConverter.FillEntityFromDTO(usersDTO, user);
                    context.Users.Add(user);


                    // user.UserId = usersDTO.UserId;
                    //employee.EmployeeId = usersDTO.EmployeesDTO.EmployeeId;
                    context.SaveChanges();
                    createUserRetval = usersDTO;
                }
            }
            catch (Exception ex)
            {
                ExceptionManager.HandleException(ex);
                throw new DACException(ex.Message);
            }
            return(createUserRetval);
        }
        public bool UpdateNotice(INoticeDTO noticeDTO)
        {
            bool retVal = false;

            using (EmployeePortalEntities employeePortalEntities = new EmployeePortalEntities())
            {
                try
                {
                    var noticeEntity = employeePortalEntities.Notices.FirstOrDefault(notice => notice.NoticeId == noticeDTO.NoticeId);
                    if (noticeEntity != null)
                    {
                        noticeEntity.Title          = noticeDTO.Title;
                        noticeEntity.Description    = noticeDTO.Description;
                        noticeEntity.StartDate      = noticeDTO.StartDate;
                        noticeEntity.ExpirationDate = noticeDTO.ExpirationDate;
                        employeePortalEntities.SaveChanges();
                        retVal = true;
                    }
                }
                catch (Exception ex)
                {
                    ExceptionManager.HandleException(ex);
                    throw new DACException(ex.Message, ex);
                }
            }
            return(retVal);
        }
Exemple #13
0
        public async Task <IHttpActionResult> LikeUser(int id, int recipientId)
        {
            //if (id != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value))
            //    return Unauthorized();

            var like = await _repo.GetLike(id, recipientId);

            if (like != null)
            {
                return(BadRequest("You already like this user"));
            }

            if (await _repo.GetUser(recipientId) == null)
            {
                return(NotFound());
            }

            like = new Like
            {
                LikerId = id,
                LikeeId = recipientId
            };

            db.Likes.Add(like);

            db.SaveChanges();
            return(Ok());

            // return BadRequest("Failed to like user");
        }
        public IList <INoticesDTO> GetActiveNotices()
        {
            List <INoticesDTO> activeNotices = new List <INoticesDTO>();

            try
            {
                using (EmployeePortalEntities context = new EmployeePortalEntities())
                {
                    //check whether we need to check here whether notice is active or not
                    foreach (var notice in context.Notices.Where(item => item.IsActive == true))
                    {
                        INoticesDTO noticeDTO = (INoticesDTO)DTOFactory.Instance.Create(DTOType.NoticesDTO);
                        EntityConverter.FillDTOFromEntity(notice, noticeDTO);
                        activeNotices.Add(noticeDTO);
                        context.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionManager.HandleException(ex);
                throw new DACException(ex.Message);
            }
            return(activeNotices);
        }
        public bool UpdateEmployee(IEmployeeDTO employeeDTO)
        {
            bool retVal = false;

            using (EmployeePortalEntities employeePortalEntities = new EmployeePortalEntities())
            {
                try
                {
                    var employeeEntity = employeePortalEntities.Employees.FirstOrDefault(employee => employee.EmployeeId == employeeDTO.EmployeeId);
                    if (employeeEntity != null)
                    {
                        employeeEntity.FirstName = employeeDTO.FirstName;
                        employeeEntity.LastName  = employeeDTO.LastName;
                        employeeEntity.Email     = employeeDTO.Email;
                        employeePortalEntities.SaveChanges();
                        retVal = true;
                    }
                }
                catch (Exception ex)
                {
                    ExceptionManager.HandleException(ex);
                    throw new DACException(ex.Message, ex);
                }
            }
            return(retVal);
        }
        public int InsertNotice(INoticeDTO noticeDTO)
        {
            int retVal = default(int);

            using (EmployeePortalEntities employeePortalEntities = new EmployeePortalEntities())
            {
                try
                {
                    Notice newNotice = new Notice();
                    //EntityConverter.FillEntityFromDTO(noticeDTO, newNotice);
                    newNotice.Title          = noticeDTO.Title;
                    newNotice.Description    = noticeDTO.Description;
                    newNotice.StartDate      = noticeDTO.StartDate;
                    newNotice.ExpirationDate = noticeDTO.ExpirationDate;
                    newNotice.PostedBy       = noticeDTO.PostedById;

                    Notice addedNotice = employeePortalEntities.Notices.Add(newNotice);
                    employeePortalEntities.SaveChanges();

                    retVal = addedNotice.NoticeId;
                }
                catch (Exception ex)
                {
                    ExceptionManager.HandleException(ex);
                    throw new DACException(ex.Message, ex);
                }
            }
            return(retVal);
        }
        public ActionResult Create([Bind(Include = "Id,Name,JobDescription,Number,Department,HourlyPay,Bonus,EmployeeTypeId")] Employee employee)
        {
            if (ModelState.IsValid)
            {
                EmployeeManagerFactory empFactory = new EmployeeManagerFactory();
                IEmployeeManager       empManager = empFactory.GetEmployeeManager(employee.EmployeeTypeId);
                employee.Bonus     = empManager.GetBonus();
                employee.HourlyPay = empManager.GetPay();
                db.Employees.Add(employee);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.EmployeeTypeId = new SelectList(db.Employee_Type, "Id", "EmployeeType", employee.EmployeeTypeId);
            return(View(employee));
        }
        public IIssueHistoriesDTO UpdateIssueByAdmin(IIssueHistoriesDTO issueHistoriesDTO)
        {
            IIssueHistoriesDTO retVal = null;

            try
            {
                using (EmployeePortalEntities context = new EmployeePortalEntities())
                {
                    var updateIssueByAdmin = context.IssueHistories.First(item => issueHistoriesDTO.IssueId == item.IssueId);
                    if (updateIssueByAdmin != null)
                    {
                        issueHistoriesDTO.IssueHistoryId = updateIssueByAdmin.IssueHistoryId;
                        EntityConverter.FillEntityFromDTO(issueHistoriesDTO, updateIssueByAdmin);
                        context.SaveChanges();
                        retVal = issueHistoriesDTO;
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionManager.HandleException(ex);
                throw new DACException(ex.Message);
            }
            return(retVal);
        }
        public IIssuesDTO CreateIssue(IIssuesDTO issuesDTO)
        {
            IIssuesDTO createIssueRetval = null;

            try
            {
                using (EmployeePortalEntities context = new EmployeePortalEntities())
                {
                    Issue issue = new Issue();
                    issuesDTO.IsActive = true;
                    EntityConverter.FillEntityFromDTO(issuesDTO, issue);
                    context.Issues.Add(issue);

                    issuesDTO.IssueHistoriesDTO.AssignedTo = 1;
                    issuesDTO.IssueHistoriesDTO.Comments   = "new issue has been generated";
                    issuesDTO.IssueHistoriesDTO.ModifiedBy = 1;
                    issuesDTO.IssueHistoriesDTO.Status     = 1;
                    issuesDTO.IssueHistoriesDTO.ModifiedOn = DateTime.Now;
                    issuesDTO.IssueHistoriesDTO.IssueId    = issue.IssueId;

                    IssueHistory newissueHistory = new IssueHistory();
                    EntityConverter.FillEntityFromDTO(issuesDTO.IssueHistoriesDTO, newissueHistory);
                    context.IssueHistories.Add(newissueHistory);
                    context.SaveChanges();

                    createIssueRetval = issuesDTO;
                }
            }
            catch (Exception ex)
            {
                ExceptionManager.HandleException(ex);
                throw new DACException(ex.Message);
            }
            return(createIssueRetval);
        }
        public ActionResult BuildLaptop(FormCollection formCollection)
        {
            Employee             employee             = db.Employees.Find(Convert.ToInt32(formCollection["employeeID"]));
            ISystemBuilder       systemBuilder        = new LaptopBuilder();
            ConfigurationBuilder configurationBuilder = new ConfigurationBuilder();

            configurationBuilder.BuildSystem(systemBuilder, formCollection);

            ComputerSystem computerSystem = systemBuilder.GetComputerSystem();

            employee.SystemConfigurationDetails = string.Format("RAM : {0}, HDDSize : {1}, KeyBoard : {2}, Mouse : {3}, TouchScreen : {4}",
                                                                computerSystem.RAM, computerSystem.HDDSize, computerSystem.KeyBoard, computerSystem.Mouse, computerSystem.TouchScreen);

            db.Entry(employee).State = EntityState.Modified;
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemple #21
0
        public ActionResult Create([Bind(Include = "Id,Name,JobDescription,Number,Department,HourlyPay,Bonus,EmployeeTypeID")] Employee employee)
        {
            if (ModelState.IsValid)
            {
                BaseEmployeeFactory employeeManagerFactory = new EmployeeManagerFactory().CreateFactory(employee);
                employeeManagerFactory.ApplySalary();
                IComputerFactory      factory = new EmployeeSystemFactory().Create(employee);
                EmployeeSystemManager manager = new EmployeeSystemManager(factory);
                employee.ComputerDetails = manager.GetSystemDetails();
                db.Employee.Add(employee);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.EmployeeTypeID = new SelectList(db.Employee_Type, "Id", "EmployeeType", employee.EmployeeTypeID);
            return(View(employee));
        }
Exemple #22
0
        public ActionResult BuildDesktop(FormCollection formcollection)
        {
            //Step 1
            Employee employee = db.Employees.Find(Convert.ToInt32(formcollection["employeeID"]));
            //Step 2 Concrete Build
            ISystemBuilder systemBuilder = new DesktopBuilder();
            //Step 3: Director
            ConfigurationBuilder builder = new ConfigurationBuilder();

            builder.BuildSystem(systemBuilder, formcollection);
            //Step 4: Reuturn System Built
            ComputerSystem system = systemBuilder.GetSystem();

            employee.SystemConfiguration = string.Format("RAM : {0}, Keyboard: {1}, Mouse: {2}, Touchscreen: {3}, HDDDrive: {4}",
                                                         system.RAM, system.KeyBoard, system.Mouse, system.TouchScreen, system.HDDSize);
            db.Entry(employee).State = EntityState.Modified;
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public ActionResult BuildLaptop(FormCollection formCollection)
        {
            Employee employee = db.Employee.Find(Convert.ToInt32(formCollection["employeeID"]));

            //Concrete builder
            ISystemBuilder systemBuilder = new LaptopBuilder();

            //Director
            ConfigurationBuilder builder = new ConfigurationBuilder();

            builder.BuildSystem(systemBuilder, formCollection);

            ComputerSystem computerSystem = systemBuilder.GetSystem();

            employee.SystemConfigurationDetails =
                string.Format("Ram: {0}, HDDSize: {1}, TouchS: {2}",
                              computerSystem.RAM, computerSystem.HDDSize, computerSystem.TouchScreen);
            db.Entry(employee).State = EntityState.Modified;
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public ActionResult BuildDesktop(FormCollection formCollection)
        {
            //step 1
            Employee employee = db.Employees.Find(Convert.ToInt32(formCollection["employeeID"]));
            //step 2 concrete builder
            ISystemBuilder systemBuilder = new DesktopBuilder();

            //step 3 Director
            ConfigurationBuilder builder = new ConfigurationBuilder();

            builder.BuildSystem(systemBuilder, formCollection);

            //step 4 return the system
            ComputerSystem system = systemBuilder.GetSystem();

            employee.SystemConfigurationDetails =
                string.Format("RAM:{0},HDDSize:{1},KeyBoard:{2},Mouse:{3}"
                              , system.RAM, system.HDDSize, system.KeyBoard, system.Mouse);
            db.Entry(employee).State = EntityState.Modified;
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemple #25
0
 public HttpResponseMessage Post([FromBody] Employee employee)
 {
     try
     {
         using (EmployeePortalEntities entities = new EmployeePortalEntities())
         {
             entities.Employees.Add(employee);
             entities.SaveChanges();
             var message = Request.CreateResponse(HttpStatusCode.Created, employee);
             message.Headers.Location = new Uri(Request.RequestUri + employee.Id.ToString());
             return(message);
         }
     }
     catch (Exception ex)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
     }
 }
        public int AddEmployee(IEmployeeDTO employeeDTO, ISecurityDTO securityDTO)
        {
            int retVal = default(int);

            using (EmployeePortalEntities employeePortalEntities = new EmployeePortalEntities())
            {
                try
                {
                    Employee employee = new Employee();
                    employee.EmployeeCode  = employeeDTO.EmployeeCode;
                    employee.FirstName     = employeeDTO.FirstName;
                    employee.LastName      = employeeDTO.LastName;
                    employee.Email         = employeeDTO.Email;
                    employee.DOB           = employeeDTO.DOB;
                    employee.DateOfJoining = employeeDTO.DateOfJoining;
                    employee.DepartmentId  = employeeDTO.DepartmentId;
                    Employee addedEmployee = employeePortalEntities.Employees.Add(employee);

                    Login login            = new Login();
                    var   departmentEntity = employeePortalEntities.Departments.FirstOrDefault(department => department.DepartmentId == employeeDTO.DepartmentId);
                    login.Role       = (departmentEntity.DepartmentName.Equals("Administration")) ? "A" : "U";
                    login.LoginName  = securityDTO.LoginName;
                    login.Password   = securityDTO.Password;
                    login.EmployeeId = addedEmployee.EmployeeId;
                    employeePortalEntities.Logins.Add(login);

                    employeePortalEntities.SaveChanges();
                    retVal = addedEmployee.EmployeeId;
                }
                catch (Exception ex)
                {
                    ExceptionManager.HandleException(ex);
                    throw new DACException(ex.Message, ex);
                }
            }

            return(retVal);
        }
        public int AddEmployee(IEmployeeDTO employeeDTO, ISecurityDTO securityDTO)
        {
            int retVal = default(int);

            using(EmployeePortalEntities employeePortalEntities = new EmployeePortalEntities())
            {
                try
                {
                    Employee employee = new Employee();
                    employee.EmployeeCode = employeeDTO.EmployeeCode;
                    employee.FirstName = employeeDTO.FirstName;
                    employee.LastName = employeeDTO.LastName;
                    employee.Email = employeeDTO.Email;
                    employee.DOB = employeeDTO.DOB;
                    employee.DateOfJoining = employeeDTO.DateOfJoining;
                    employee.DepartmentId = employeeDTO.DepartmentId;
                    Employee addedEmployee = employeePortalEntities.Employees.Add(employee);

                    Login login = new Login();
                    var departmentEntity = employeePortalEntities.Departments.FirstOrDefault(department => department.DepartmentId == employeeDTO.DepartmentId);
                    login.Role = (departmentEntity.DepartmentName.Equals("Administration")) ? "A" : "U";
                    login.LoginName = securityDTO.LoginName;
                    login.Password = securityDTO.Password;
                    login.EmployeeId = addedEmployee.EmployeeId;
                    employeePortalEntities.Logins.Add(login);

                    employeePortalEntities.SaveChanges();
                    retVal = addedEmployee.EmployeeId;
                }
                catch (Exception ex)
                {
                    ExceptionManager.HandleException(ex);
                    throw new DACException(ex.Message, ex);
                }
            }

            return retVal;
        }
        public INoticesDTO UpdateNotice(INoticesDTO noticesDTO)
        {
            INoticesDTO retVal = null;

            try
            {
                using (EmployeePortalEntities context = new EmployeePortalEntities())
                {
                    var updateNotice = context.Notices.First(item => noticesDTO.NoticeId == item.NoticeId);
                    if (updateNotice != null)
                    {
                        EntityConverter.FillEntityFromDTO(noticesDTO, updateNotice);
                        context.SaveChanges();
                        retVal = noticesDTO;
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionManager.HandleException(ex);
                throw new DACException(ex.Message);
            }
            return(retVal);
        }
        public INoticesDTO CreateNotice(INoticesDTO noticesDTO)
        {
            INoticesDTO createNoticeRetval = null;

            try
            {
                using (EmployeePortalEntities context = new EmployeePortalEntities())
                {
                    noticesDTO.IsActive = true;
                    Notice notice = new Notice();
                    EntityConverter.FillEntityFromDTO(noticesDTO, notice);
                    context.Notices.Add(notice);
                    context.SaveChanges();
                    notice.NoticeId    = noticesDTO.NoticeId;
                    createNoticeRetval = noticesDTO;
                }
            }
            catch (Exception ex)
            {
                ExceptionManager.HandleException(ex);
                throw new DACException(ex.Message);
            }
            return(createNoticeRetval);
        }
        public IList <INoticesDTO> GetCurrentNotices()
        {
            List <INoticesDTO> currentNotices = new List <INoticesDTO>();

            try
            {
                using (EmployeePortalEntities context = new EmployeePortalEntities())
                {
                    foreach (var notice in context.Notices.Where(i => ((i.StartDate <= DateTime.Now) && (i.ExpirationDate >= DateTime.Now)) && i.IsActive == true))
                    {
                        INoticesDTO noticeDTO = (INoticesDTO)DTOFactory.Instance.Create(DTOType.NoticesDTO);
                        EntityConverter.FillDTOFromEntity(notice, noticeDTO);
                        currentNotices.Add(noticeDTO);
                        context.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionManager.HandleException(ex);
                throw new DACException(ex.Message);
            }
            return(currentNotices);
        }
Exemple #31
0
 public HttpResponseMessage Delete(int id)
 {
     try
     {
         using (EmployeePortalEntities entities = new EmployeePortalEntities())
         {
             var entity = entities.Employees.Remove(entities.Employees.FirstOrDefault(x => x.Id == id));
             if (entity == null)
             {
                 return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Employee with id :" + id.ToString() + " not available to delete"));
             }
             else
             {
                 entities.Employees.Remove();
                 entities.SaveChanges();
                 return(Request.CreateResponse(HttpStatusCode.ok));
             }
         }
     }
     catch (Exception ex)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
     }
 }
 public bool UpdateEmployee(IEmployeeDTO employeeDTO)
 {
     bool retVal = false;
     using (EmployeePortalEntities employeePortalEntities = new EmployeePortalEntities())
     {
         try
         {
             var employeeEntity = employeePortalEntities.Employees.FirstOrDefault(employee => employee.EmployeeId == employeeDTO.EmployeeId);
             if (employeeEntity != null)
             {
                 employeeEntity.FirstName = employeeDTO.FirstName;
                 employeeEntity.LastName = employeeDTO.LastName;
                 employeeEntity.Email = employeeDTO.Email;
                 employeePortalEntities.SaveChanges();
                 retVal = true;
             }
         }
         catch (Exception ex)
         {
             ExceptionManager.HandleException(ex);
             throw new DACException(ex.Message, ex);
         }
     }
     return retVal;
 }