public IActionResult Create([FromBody] Timesheet timesheet)
 {
     Debug.WriteLine("Getting Here");
     if (timesheet == null)
     {
         return(BadRequest());
     }
     Debug.WriteLine(timesheet);
     timesheetRepository.InsertTimesheet(timesheet);
     timesheetRepository.Save();
     return(Created("GettimesheetById", timesheet));
 }
        // POST api/timesheets
        public HttpResponseMessage Post([FromBody] Timesheet timesheet)
        {
            var opStatus = _TimesheetRepository.InsertTimesheet(timesheet);

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

            //Generate success response
            var    response = Request.CreateResponse <OperationStatus>(HttpStatusCode.Created, opStatus);
            string uri      = Url.Link("DefaultApi", new { id = opStatus.OperationID });

            response.Headers.Location = new Uri(uri);
            return(response);
        }
Beispiel #3
0
 public IActionResult Post([FromBody] Timesheet timesheet)
 {
     timesheet.OnCreation();
     return(Ok(_timeSheetRepository.InsertTimesheet(timesheet)));
 }