public HttpResponseMessage GetWorkingTime([FromUri] WorkingTimeModel workingTime)
        {
            try
            {
                IList <WorkingTime> listtime = null;
                listtime = workingTimeManager.GetWorkingTimes(workingTime);
                if (listtime == null)
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "There are no working time match the search value!!!"));
                }

                return(Request.CreateResponse(HttpStatusCode.OK, new { WorkingTimeModel = listtime }));
            }
            catch (Exception e)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Error occured while executing GetWorkingTime:" + e.Message));
            }
        }
 public bool UpdateWorkingTime(WorkingTimeModel workingTime)
 {
     using (var ctx = new SalaryManagement_SWD391_ProjectEntities_WorkingTime())
     {
         var checkExistingWorkingTime = ctx.WorkingTimes.Where(c => c.WorkingTimeID == workingTime.WorkingTimeID).FirstOrDefault <WorkingTime>();
         if (checkExistingWorkingTime != null)
         {
             checkExistingWorkingTime.EmployeeID = workingTime.EmployeeID;
             checkExistingWorkingTime.PeriodID   = workingTime.PeriodID;
             checkExistingWorkingTime.WorkedTime = (double)workingTime.WorkedTime;
             ctx.SaveChanges();
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
        public IList <WorkingTime> GetWorkingTimes(WorkingTimeModel workingTime)
        {
            IList <WorkingTime> listtime = null;

            using (var ctx = new SalaryManagement_SWD391_ProjectEntities_WorkingTime())
            {
                if (workingTime != null)
                {
                    listtime = ctx.WorkingTimes.Where(c => (c.WorkingTimeID.Contains(workingTime.WorkingTimeID) || workingTime.WorkingTimeID == null) &&
                                                      (c.EmployeeID.Contains(workingTime.EmployeeID) || workingTime.EmployeeID == null) &&
                                                      (c.PeriodID.Contains(workingTime.PeriodID) || workingTime.PeriodID == null) &&
                                                      (c.WorkedTime == workingTime.WorkedTime || workingTime.WorkedTime == null)
                                                      ).ToList <WorkingTime>();
                }
                else
                {
                    listtime = ctx.WorkingTimes.ToList <WorkingTime>();
                }
            }
            return(listtime);
        }
 public HttpResponseMessage PutWorkingTime(WorkingTimeModel workingTime)
 {
     try
     {
         if (!ModelState.IsValid)
         {
             return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Invalid data!!!"));
         }
         bool check = workingTimeManager.UpdateWorkingTime(workingTime);
         if (check)
         {
             return(Request.CreateResponse(HttpStatusCode.OK, "working time updated!"));
         }
         else
         {
             return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "working time not found!!!"));
         }
     }
     catch (Exception e)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Error occured while executing Put:" + e.Message));
     }
 }