Пример #1
0
        private void Update(int resource_id, DateTime myDate, FormCollection coll)
        {
            timedb.DeleteTimesheet(resource_id, myDate);
            List <day> myEntries = new List <day>();


            foreach (var item in coll)
            {
                if (item.ToString().Contains("r"))
                {
                    if (coll[item.ToString()] != string.Empty)
                    {
                        myEntries.Add(new day {
                            Day = int.Parse(item.ToString().Replace("r", "")), Year = myDate.Year, Month = myDate.Month, HoursWorked = decimal.Parse(coll[item.ToString()].ToString())
                        });
                    }
                }
            }
            foreach (var h in myEntries)
            {
                tbl_TimeSheet mytime = new tbl_TimeSheet();
                mytime.Resource_ID = resource_id;
                mytime.Date        = new DateTime(h.Year, h.Month, h.Day);
                mytime.Hours       = (decimal)h.HoursWorked;
                timedb.Add(mytime);
            }
            timedb.Save();
        }
Пример #2
0
        public IActionResult DeleteAbsence(int id)
        {
            var timesheet = _timesheetRepository.GetTimesheet(id);

            if (timesheet == null || timesheet.UserId != GetUserId() || !timesheet.Absence)
            {
                return(BadRequest());
            }

            _timesheetRepository.DeleteTimesheet(id);
            return(Ok());
        }
Пример #3
0
        // DELETE api/timesheets/5
        public HttpResponseMessage Delete(int id)
        {
            var opStatus = _TimesheetRepository.DeleteTimesheet(id);

            if (!opStatus.Status)
            {
                throw new HttpResponseException(Request.CreateResponse <OperationStatus>(HttpStatusCode.NotFound, opStatus));
            }

            //Generate success response
            var response = Request.CreateResponse <OperationStatus>(HttpStatusCode.OK, opStatus);

            return(response);
        }
 public async Task <ActionResult> DeleteTimesheet(long timesheetId)
 {
     try
     {
         await _timesheetRepository.DeleteTimesheet(timesheetId);
     }
     catch (KeyNotFoundException e)
     {
         return(NotFound(e.Message));
     }
     catch (ArgumentException e)
     {
         return(BadRequest(e.Message));
     }
     return(NoContent());
 }