private HttpResponseMessage ProcessNewFinishTimeRecord(HttpRequestMessage request, FinishTimeDTO uDto, string key, int FinishTimeId, int userId)
        {
            var ur   = new FinishTimeRepository();
            var user = new FinishTime();


            var validationErrors = GetValidationErrors(ur, user, uDto, FinishTimeId, userId);

            if (validationErrors.Any())
            {
                return(ProcessValidationErrors(request, validationErrors, key));
            }

            user = ur.Save(user);

            UpdateDepartmentTotalFinishTime(uDto);
            uDto.Key          = key;
            uDto.FinishTimeID = user.FinishTimeID.ToString();
            var response = request.CreateResponse(HttpStatusCode.Created, uDto);

            response.Headers.Location = new Uri(Url.Link("Default", new
            {
                id = user.FinishTimeID
            }));
            return(response);
        }
        private HttpResponseMessage ProcessExistingFinishTimeRecord(HttpRequestMessage request, FinishTimeDTO cqDto, int contactId, string key, int FinishTimeId, int userId)
        {
            var ur   = new FinishTimeRepository();
            var user = new FinishTime();

            user = ur.GetById(contactId);


            var validationErrors = GetValidationErrors(ur, user, cqDto, FinishTimeId, userId);

            if (validationErrors.Any())
            {
                return(ProcessValidationErrors(request, validationErrors, key));
            }

            //if (cqDto.Remove != null && int.Parse(cqDto.Remove) == 1)
            //{
            //    ur.Delete(user);
            //}
            else
            {
                ur.Save(user);
            }

            UpdateDepartmentTotalFinishTime(cqDto);

            cqDto.Key = key;
            return(request.CreateResponse(HttpStatusCode.Accepted, cqDto));
        }
        private HttpResponseMessage ProcessNewFinishTimeRecord(HttpRequestMessage request, FinishTimeDTO uDto, string key, int FinishTimeId, int userId)
        {
            var ur = new FinishTimeRepository();
            var user = new FinishTime();

            var validationErrors = GetValidationErrors(ur, user, uDto, FinishTimeId, userId);

            if (validationErrors.Any())
            {
                return ProcessValidationErrors(request, validationErrors, key);
            }

            user = ur.Save(user);

            UpdateDepartmentTotalFinishTime(uDto);
            uDto.Key = key;
            uDto.FinishTimeID = user.FinishTimeID.ToString();
            var response = request.CreateResponse(HttpStatusCode.Created, uDto);
            response.Headers.Location = new Uri(Url.Link("Default", new
            {
                id = user.FinishTimeID
            }));
            return response;
        }
        private HttpResponseMessage ProcessExistingFinishTimeRecord(HttpRequestMessage request, FinishTimeDTO cqDto, int contactId, string key, int FinishTimeId, int userId)
        {
            var ur = new FinishTimeRepository();
            var user = new FinishTime();
            user = ur.GetById(contactId);

            var validationErrors = GetValidationErrors(ur, user, cqDto, FinishTimeId, userId);
            if (validationErrors.Any())
            {
                return ProcessValidationErrors(request, validationErrors, key);
            }

            //if (cqDto.Remove != null && int.Parse(cqDto.Remove) == 1)
            //{
            //    ur.Delete(user);
            //}
            else
            {
                ur.Save(user);
            }

            UpdateDepartmentTotalFinishTime(cqDto);

            cqDto.Key = key;
            return request.CreateResponse(HttpStatusCode.Accepted, cqDto);
        }