Beispiel #1
0
        public IHttpActionResult Posttimesheet(TimeSheetDTO input)
        {
            TextResult       httpResponse = new TextResult("There is already a timesheet present", message);
            TimesheetManager manager      = new TimesheetManager();

            var timesheetObject = manager.CreateTimeSheet(input.User_id, input.Start_date, input.Start_time.ToString(), input.Project_id, input.Activity_id);;

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            try
            {
                db.timesheet.Add(timesheetObject);
                db.SaveChanges();
            }
            catch
            {
                httpResponse.ChangeHTTPMessage("Failed to create timesheet", message); // HTTP response if fails to savechanges to DB
                return(httpResponse);
            }

            return(Ok());
        }