Exemplo n.º 1
0
 public void Update(EmployeeOvertimeVM employeeovertimeVM)
 {
     this.StartTime  = employeeovertimeVM.StartTime;
     this.EndTime    = employeeovertimeVM.EndTime;
     this.Activity   = employeeovertimeVM.Activity;
     this.UpdateDate = DateTimeOffset.Now.LocalDateTime;
 }
        // PUT: api/EmployeeOvertimes/5

        /*public HttpResponseMessage UpdateEmployeeOvertime(int id, EmployeeOvertimeVM employeeOvertimeVM)
         * {
         *  var message = Request.CreateErrorResponse(HttpStatusCode.NotFound, "Bad Request");
         *  if (string.IsNullOrWhiteSpace(id.ToString()))
         *  {
         *      message = Request.CreateErrorResponse(HttpStatusCode.NotFound, "Invalid Id");
         *  }
         *  else
         *  {
         *      var get = _iEmployeeOvertimeService.Update(id, employeeOvertimeVM);
         *      if (get)
         *      {
         *          message = Request.CreateResponse(HttpStatusCode.OK, get);
         *          return message;
         *      }
         *  }
         *  return message;
         * }*/

        // POST: api/EmployeeOvertimes
        public HttpResponseMessage InsertEmployeeOvertime(EmployeeOvertimeVM employeeOvertimeVM)
        {
            var message = Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Wrong Parameter");
            var result  = _iEmployeeOvertimeService.Insert(employeeOvertimeVM);

            if (result)
            {
                message = Request.CreateResponse(HttpStatusCode.OK, "Successfully Added");
            }
            return(message);
        }
 public bool Insert(EmployeeOvertimeVM employeeovertimeVM)
 {
     if (string.IsNullOrWhiteSpace(employeeovertimeVM.StartTime.ToString()) || string.IsNullOrWhiteSpace(employeeovertimeVM.EndTime.ToString()) || string.IsNullOrWhiteSpace(employeeovertimeVM.Activity.ToString()) || string.IsNullOrWhiteSpace(employeeovertimeVM.EmployeeId.ToString()) || string.IsNullOrWhiteSpace(employeeovertimeVM.OvertimeRequestId.ToString()))
     {
         return(status);
     }
     else
     {
         var result = _employeeOvertimeRepository.Insert(employeeovertimeVM);
         return(result);
     }
 }
        public bool Insert(EmployeeOvertimeVM employeeovertimeVM)
        {
            var push        = new EmployeeOvertime(employeeovertimeVM);
            var getEmployee = applicationContext.Employees.SingleOrDefault(x => x.IsDelete == false && x.Id == employeeovertimeVM.EmployeeId);

            push.Employee = getEmployee;
            var getOvertime = applicationContext.OvertimeRequests.SingleOrDefault(x => x.IsDelete == false && x.Id == employeeovertimeVM.OvertimeRequestId);

            push.OvertimeRequest = getOvertime;
            applicationContext.EmployeeOvertimes.Add(push);
            var result = applicationContext.SaveChanges();

            return(result > 0);
        }
Exemplo n.º 5
0
 public void Delete(EmployeeOvertimeVM employeeovertimeVM)
 {
     this.IsDelete   = true;
     this.DeleteDate = DateTimeOffset.Now.LocalDateTime;
 }