Exemple #1
0
        public IActionResult StopTimesheet(int id)
        {
            var repo = this.Storage.GetRepository <ITimesheetRepository>();

            Timesheet timesheet = repo.WithKey(id);

            if (timesheet == null)
            {
                return(this.NotFound(new { success = false }));
            }


            if (this.ModelState.IsValid)
            {
                timesheet.Stop();
                repo.Edit(timesheet, GetCurrentUserName());
                this.Storage.Save();

                return(Ok(new { success = true }));
            }

            return(BadRequest(new { success = false }));
        }