Exemple #1
0
        public IHttpActionResult Post([FromBody] DayModel model)
        {
            try
            {
                Day day = new Day
                {
                    Id         = model.Id,
                    Date       = model.Date,
                    Category   = TimeUnit.Categories.Get(model.Type),
                    Hours      = model.Hours,
                    Employee   = TimeUnit.Employees.Get(model.Employee.Id),
                    CategoryId = model.Type,
                    EmployeeId = model.Employee.Id
                };
                if (day.Id == 0)
                {
                    TimeUnit.Days.Insert(day);
                }
                else
                {
                    TimeUnit.Days.Update(day, day.Id);
                }
                TimeUnit.Save();

                foreach (DetailModel task in model.Details)
                {
                    if (task.Deleted)
                    {
                        TimeUnit.Assignments.Delete(task.Id);
                    }
                    else
                    {
                        Assignment detail = new Assignment
                        {
                            Id          = task.Id,
                            Day         = TimeUnit.Days.Get(day.Id),
                            DayId       = day.Id,
                            Description = task.Description,
                            Hours       = task.Hours,
                            Project     = TimeUnit.Projects.Get(task.Project.Id),
                            ProjectId   = task.Project.Id
                        };
                        if (detail.Id == 0)
                        {
                            TimeUnit.Assignments.Insert(detail);
                        }
                        else
                        {
                            TimeUnit.Assignments.Update(detail, detail.Id);
                        }
                    }
                }
                TimeUnit.Save();
                return(Ok());
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Exemple #2
0
        public IHttpActionResult Delete(int id)
        {
            try
            {
                Employee employee = TimeUnit.Employees.Get(id);
                if (employee == null)
                {
                    Utility.Log($"Delete employee failed. Wrong id.", "ERROR");
                    return(NotFound());
                }

                //DaysController days = new DaysController();
                //foreach (var eng in TimeUnit.Days.Get().Where(x => x.Employee.Id == id))
                //{
                //    days.Delete(eng.Id);
                //}

                //EngagementsController members = new EngagementsController();
                //foreach (var eng in TimeUnit.Engagements.Get().Where(x => x.Employee.Id == id))
                //{
                //    members.Delete(eng.Id);
                //}

                TimeUnit.Employees.Delete(employee);
                TimeUnit.Save();
                Utility.Log($"Deleted employee with id " + id + ".", "INFO");
                return(Ok());
            }
            catch (Exception ex)
            {
                Utility.Log($"Delete employee failed.", "ERROR");
                return(BadRequest(ex.Message));
            }
        }
Exemple #3
0
        /// <summary>
        /// Insert Engagement.
        /// </summary>
        /// <param name="engagement"></param>
        /// <returns></returns>
        /// <response code="200">Returns the newly-created item</response>
        /// <response code="400">If the item is null</response>

        public IHttpActionResult Post([FromBody] Engagement engagement)
        {
            try
            {
                List <string> errors = ValidateExtensions.ValidateEngagements(engagement);

                if (errors.Count > 0)
                {
                    return(Content(HttpStatusCode.BadRequest, errors));
                }

                engagement.Team     = TimeUnit.Teams.Get(engagement.Team.Id);
                engagement.Role     = TimeUnit.Roles.Get(engagement.Role.Id);
                engagement.Employee = TimeUnit.Employees.Get(engagement.Employee.Id);

                TimeUnit.Engagements.Insert(engagement);
                TimeUnit.Save();
                Utility.Log($"ENGAGEMENT CONTROLLER: Post Called on Engagement, Successfully added: {engagement.Id}.", "INFO");
                return(Ok(TimeFactory.Create(engagement)));
            }

            catch (Exception ex)

            {
                Utility.Log($"ENGAGEMENT CONTROLLER: Post Cannot be called on Engagement.", "ERROR", ex);
                return(BadRequest(ex.Message));
            }
        }
Exemple #4
0
        public IHttpActionResult Post([FromBody] Employee employee)
        {
            try
            {
                List <string> errors = ValidateExtensions.ValidateEmployee(employee);

                if (errors.Count > 0)
                {
                    return(Content(HttpStatusCode.BadRequest, errors));
                }


                employee.Roles = TimeUnit.Roles.Get(employee.Roles.Id);
                employee.Image = employee.ConvertAndSave();
                TimeUnit.Employees.Insert(employee);
                TimeUnit.Save();
                Utility.Log($"EMPOLOYEE CONTROLLER: Post Called on Employee, Successfully added: {employee.FirstName + " " + employee.LastName}.", "INFO");
                return(Ok(TimeFactory.Create(employee)));
            }
            catch (Exception ex)
            {
                Utility.Log($"EMPOLOYEE CONTROLLER: Post Cannot be called on Employee.", "ERROR", ex);
                return(BadRequest(ex.Message));
            }
        }
Exemple #5
0
        /// <summary>
        /// Insert Task.
        /// </summary>
        /// <param name="task"></param>
        /// <returns></returns>
        /// <response code="200">Returns the newly-created item</response>
        /// <response code="400">If the item is null</response>

        public IHttpActionResult Post([FromBody] Task task)
        {
            try
            {
                List <string> errors = ValidateExtensions.ValidateTask(task);

                if (errors.Count > 0)
                {
                    return(Content(HttpStatusCode.BadRequest, errors));
                }

                task.Day     = TimeUnit.Days.Get(task.Day.Id);
                task.Project = TimeUnit.Projects.Get(task.Day.Id);

                TimeUnit.Tasks.Insert(task);
                TimeUnit.Save();
                Utility.Log($"ROLE CONTROLLER: Post Called on Role, Successfully added: {task.Description}.", "INFO");
                return(Ok(TimeFactory.Create(task)));
            }
            catch (Exception ex)
            {
                Utility.Log($"ROLE CONTROLLER: Post Cannot be called on Role.", "ERROR", ex);
                return(BadRequest(ex.Message));
            }
        }
 public IHttpActionResult Delete(int id)
 {
     try
     {
         Customer customer = TimeUnit.Customers.Get(id);
         if (customer == null)
         {
             return(NotFound());
         }
         foreach (var proj in customer.Projects)
         {
             TimeUnit.Projects.Delete(proj.Id);
             break;
         }
         TimeUnit.Customers.Delete(customer);
         TimeUnit.Save();
         Utility.Log($"Delete data for customer with ID = {id}", "INFO");
         return(Ok());
     }
     catch (Exception ex)
     {
         Utility.Log(ex.Message, "ERROR", ex);
         return(BadRequest(ex.Message));
     }
 }
        /// <summary>
        /// Update Team by Id.
        /// </summary>
        /// <param name="id"></param>
        /// <param name="team"></param>
        /// <returns></returns>
        /// <response code="200">Returns the newly-created item</response>
        /// <response code="400">If the item is null</response>

        public IHttpActionResult Put([FromBody] Team team, string id)
        {
            List <string> errors = ValidateExtensions.ValidateTeam(team);

            if (errors.Count > 0)
            {
                return(Content(HttpStatusCode.BadRequest, errors));
            }


            try
            {
                if (TimeUnit.Teams.Get(id) == null)
                {
                    return(NotFound());
                }
                TimeUnit.Teams.Update(team, id);
                TimeUnit.Save();
                Utility.Log($"ROLE CONTROLLER: Put Called on Role, Successfully updated id: {id}.", "INFO");
                return(Ok(TimeFactory.Create(team)));
            }
            catch (Exception ex)
            {
                Utility.Log($"ROLE CONTROLLER: Put Cannot be called on Role.", "ERROR", ex);
                return(BadRequest(ex.Message));
            }
        }
        public IHttpActionResult Put([FromBody] Project project, int id)
        {
            try
            {
                Project oldProject = TimeUnit.Projects.Get(id);
                if (oldProject == null)
                {
                    return(NotFound());
                }
                project = FillNewProjectWithOldData(project, oldProject);


                //project.Customer = TimeUnit.Customers.Get(project.Customer.Id);
                //project.Team = TimeUnit.Teams.Get(project.Team.Id);
                //project.CustomerId = project.Customer.Id;
                //project.TeamId = project.Team.Id;
                TimeUnit.Projects.Update(project, id);
                TimeUnit.Save();
                Utility.Log($"Update data for project with ID = {id}", "INFO");
                return(Ok(TimeFactory.Create(project)));
            }
            catch (Exception ex)
            {
                Utility.Log(ex.Message, "ERROR", ex);
                return(BadRequest(ex.Message));
            }
        }
        public IHttpActionResult Post([FromBody] Task task)
        {
            var errors = task.Validate();

            if (errors.Count > 0)
            {
                string combindedString = string.Join(" ", errors.ToArray());
                return(BadRequest(combindedString));
            }

            try
            {
                task.Day     = TimeUnit.Days.Get(task.Day.Id);
                task.Project = TimeUnit.Projects.Get(task.Project.Id);

                TimeUnit.Tasks.Insert(task);
                TimeUnit.Save();
                Utility.Log($"Inserted new task.", "INFO");
                return(Ok(TimeFactory.Create(task)));
            }
            catch (Exception ex)
            {
                Utility.Log($"Insert task failed.", "ERROR");
                return(BadRequest(ex.Message));
            }
        }
Exemple #10
0
        public IHttpActionResult Put([FromBody] Customer customer, int id)
        {
            try
            {
                if (TimeUnit.Customer.Get(id) == null)
                {
                    Utility.Log($"Update customer failed. Wrong id.", "ERROR");
                    return(NotFound());
                }

                var errors = customer.Validate();

                if (errors.Count > 0)
                {
                    string combindedString = string.Join(" ", errors.ToArray());
                    return(BadRequest(combindedString));
                }

                //customer.Address = TimeUnit.Customer.Get().Where(x => x.Id == id).Select(y => y.Address).FirstOrDefault();

                TimeUnit.Customer.Update(customer, id);
                TimeUnit.Save();
                Utility.Log($"Updated customer with id " + id + ".", "INFO");
                return(Ok(TimeFactory.Create(customer)));
            }
            catch (Exception ex)
            {
                Utility.Log($"Update customer failed.", "ERROR");
                return(BadRequest(ex.Message));
            }
        }
        public IHttpActionResult Put([FromBody] Engagement engagement, int id)
        {
            try
            {
                if (TimeUnit.Engagements.Get(id) == null)
                {
                    Utility.Log($"Update engagement failed. Wrong id.", "ERROR");
                    return(NotFound());
                }

                var errors = engagement.Validate();

                if (errors.Count > 0)
                {
                    string combindedString = string.Join(" ", errors.ToArray());
                    return(BadRequest(combindedString));
                }

                TimeUnit.Engagements.Update(engagement, id);
                TimeUnit.Save();
                Utility.Log($"Updated engagement with id " + id + ".", "INFO");
                return(Ok(TimeFactory.Create(engagement)));
            }
            catch (Exception ex)
            {
                Utility.Log($"Update engagement failed.", "ERROR");
                return(BadRequest(ex.Message));
            }
        }
Exemple #12
0
        /// <summary>
        /// Update Customer by Id.
        /// </summary>
        /// <param name = "id"></param>
        /// <param name = "customer"></param>
        /// <returns></returns>
        /// <response code="200">Returns the newly-created item</response>
        /// <response code="400">If the item is null</response>

        public IHttpActionResult Put([FromBody] Customer customer, int id)
        {
            try
            {
                if (TimeUnit.Customers.Get(id) == null)
                {
                    return(NotFound());
                }

                List <string> errors = ValidateExtensions.ValidateCustomer(customer);

                if (errors.Count > 0)
                {
                    return(Content(HttpStatusCode.BadRequest, errors));
                }

                TimeUnit.Customers.Update(customer, id);
                //customer.Image = customer.ConvertAndSave();
                TimeUnit.Save();
                Utility.Log($"CUSTOMER CONTROLLER: Put Called on Customer, Successfully updated id: {id}.", "INFO");
                return(Ok(TimeFactory.Create(customer)));
            }
            catch (Exception ex)
            {
                Utility.Log($"CUSTOMER CONTROLLER: Put Cannot be called on Customer.", "ERROR", ex);
                return(BadRequest(ex.Message));
            }
        }
Exemple #13
0
 public IHttpActionResult Delete(int id)
 {
     try
     {
         Day day = TimeUnit.Days.Get(id);
         if (day == null)
         {
             return(NotFound());
         }
         foreach (var ass in day.Assignments)
         {
             TimeUnit.Days.Delete(ass.Id);
             break;
         }
         TimeUnit.Days.Delete(day);
         TimeUnit.Save();
         Utility.Log($"Delete data for day with ID = {id}", "INFO");
         return(Ok());
     }
     catch (Exception ex)
     {
         Utility.Log(ex.Message, "ERROR", ex);
         return(BadRequest(ex.Message));
     }
 }
Exemple #14
0
        public IHttpActionResult Post([FromBody] Employee employee)
        {
            var errors = employee.Validate();

            if (errors.Count > 0)
            {
                string combindedString = string.Join(" ", errors.ToArray());
                return(BadRequest(combindedString));
            }

            employee.Position = TimeUnit.Roles.Get(x => x.Id == employee.Position.Id).FirstOrDefault();

            try
            {
                employee.Image = employee.ConvertAndSave();

                TimeUnit.Employees.Insert(employee);
                TimeUnit.Save();
                Utility.Log($"Inserted new employee.", "INFO");
                return(Ok(TimeFactory.Create(employee)));
            }
            catch (Exception ex)
            {
                Utility.Log($"Insert employee failed.", "ERROR");
                return(BadRequest(ex.Message));
            }
        }
Exemple #15
0
        public IHttpActionResult Put([FromBody] Engagement engagement, int id)
        {
            try
            {
                Engagement oldEngagement = TimeUnit.Engagements.Get(id);
                if (oldEngagement == null)
                {
                    return(NotFound());
                }
                engagement = FillEngagementWithOldData(engagement, oldEngagement);
                //engagement.Role = TimeUnit.Roles.Get(engagement.Role.Id);
                //engagement.Team = TimeUnit.Teams.Get(engagement.Team.Id);
                //engagement.Employee = TimeUnit.Employees.Get(engagement.Employee.Id);

                //engagement.RoleId = engagement.Role.Id;
                //engagement.TeamId = engagement.Team.Id;
                //engagement.EmployeeId = engagement.Employee.Id;
                TimeUnit.Engagements.Update(engagement, id);
                TimeUnit.Save();
                Utility.Log($"Update data for ENGAGEMENT with ID = {id}", "INFO");
                return(Ok(TimeFactory.Create(engagement)));
            }
            catch (Exception ex)
            {
                Utility.Log(ex.Message, "ERROR", ex);
                return(BadRequest(ex.Message));
            }
        }
        public IHttpActionResult Post([FromBody] Engagement engagement)
        {
            var errors = engagement.Validate();

            if (errors.Count > 0)
            {
                string combindedString = string.Join(" ", errors.ToArray());
                return(BadRequest(combindedString));
            }

            engagement.Team     = TimeUnit.Teams.Get(engagement.Team.Id);
            engagement.Employee = TimeUnit.Employees.Get(engagement.Employee.Id);
            engagement.Role     = TimeUnit.Roles.Get(engagement.Role.Id);

            try
            {
                TimeUnit.Engagements.Insert(engagement);
                TimeUnit.Save();
                Utility.Log($"Inserted new engagement.", "INFO");
                return(Ok(TimeFactory.Create(engagement)));
            }
            catch (Exception ex)
            {
                Utility.Log($"Insert engagement failed.", "ERROR");
                return(BadRequest(ex.Message));
            }
        }
Exemple #17
0
 public IHttpActionResult Delete(string id)
 {
     try
     {
         Team team = TimeUnit.Teams.Get(id);
         if (team == null)
         {
             return(NotFound());
         }
         foreach (var eng in team.Engagements)
         {
             TimeUnit.Engagements.Delete(eng.Id);
             break;
         }
         //foreach (var proj in team.Projects)
         //{
         //    proj.Team.Id = TimeUnit.Teams.Get("Id benc tima");
         //}
         TimeUnit.Teams.Delete(team);
         TimeUnit.Save();
         Utility.Log($"Delete data for team with ID = {id}", "INFO");
         return(Ok());
     }
     catch (Exception ex)
     {
         Utility.Log(ex.Message, "ERROR", ex);
         return(BadRequest(ex.Message));
     }
 }
        /// <summary>
        /// Insert Project.
        /// </summary>
        /// <param name="project"></param>
        /// <returns></returns>
        /// <response code="200">Returns the newly-created item</response>
        /// <response code="400">If the item is null</response>

        public IHttpActionResult Post([FromBody] Project project)
        {
            try
            {
                List <string> errors = ValidateExtensions.ValidateProject(project);

                if (errors.Count > 0)
                {
                    return(Content(HttpStatusCode.BadRequest, errors));
                }

                project.Customer = TimeUnit.Customers.Get(project.CustomerId);
                project.Team     = TimeUnit.Teams.Get(project.TeamId);
                TimeUnit.Projects.Insert(project);
                TimeUnit.Save();
                Utility.Log($"PROJECT CONTROLLER: Post Called on Project, Successfully added: {project.Name}.", "INFO");
                return(Ok(TimeFactory.Create(project)));
            }

            catch (Exception ex)

            {
                Utility.Log($"PROJECT CONTROLLER: Post Cannot be called on Project.", "ERROR", ex);
                return(BadRequest(ex.Message));
            }
        }
        /// <summary>
        /// Update Project by Id.
        /// </summary>
        /// <param name="id"></param>
        /// <param name="project"></param>
        /// <returns></returns>
        /// <response code="200">Returns the newly-created item</response>
        /// <response code="400">If the item is null</response>

        public IHttpActionResult Put([FromBody] Project project, int id)
        {
            try
            {
                Project oldProject = TimeUnit.Projects.Get(id);
                if (oldProject == null)
                {
                    return(NotFound());
                }
                project = FillNewProjectWithOldData(project, oldProject);


                //project.Customer = TimeUnit.Customers.Get(project.Customer.Id);
                //project.Team = TimeUnit.Teams.Get(project.Team.Id);
                //project.CustomerId = project.Customer.Id;
                //project.TeamId = project.Team.Id;

                TimeUnit.Projects.Update(project, id);
                TimeUnit.Save();
                Utility.Log($"PROJECT CONTROLLER: Put Called on Project, Successfully updated id: {id}.", "INFO");
                return(Ok(TimeFactory.Create(project)));
            }
            catch (Exception ex)
            {
                Utility.Log($"PROJECT CONTROLLER: Put Cannot be called on Project.", "ERROR", ex);
                return(BadRequest(ex.Message));
            }
        }
        public IHttpActionResult Post([FromBody] DayModel model)
        {
            try
            {
                Day day = new Day
                {
                    Id       = model.Id,
                    Date     = model.Date,
                    Type     = (DayType)model.Type,
                    Hours    = model.Hours,
                    Employee = TimeUnit.Employees.Get(model.EmployeeId)
                               //Employee = TimeUnit.Employees.Get(model.EmployeeId)
                };
                if (day.Id == 0)
                {
                    TimeUnit.Days.Insert(day);
                }
                else
                {
                    TimeUnit.Days.Update(day, day.Id);
                }
                TimeUnit.Save();

                foreach (DetailModel task in model.Details)
                {
                    Task detail = new Task
                    {
                        Id          = task.Id,
                        Day         = TimeUnit.Days.Get(day.Id),
                        Description = task.Description,
                        Hours       = task.Hours,
                        Project     = TimeUnit.Projects.Get(task.Project.Id)
                    };
                    if (detail.Id == 0)
                    {
                        TimeUnit.Tasks.Insert(detail);
                    }
                    else
                    {
                        TimeUnit.Tasks.Update(detail, detail.Id);
                    }
                }
                TimeUnit.Save();
                return(Ok());
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Exemple #21
0
 public IHttpActionResult Post([FromBody] Category category)
 {
     try
     {
         TimeUnit.Categories.Insert(category);
         TimeUnit.Save();
         Utility.Log($"Insert data for category {category.Description}", "INFO");
         return(Ok(TimeFactory.Create(category)));
     }
     catch (Exception ex)
     {
         Utility.Log(ex.Message, "ERROR", ex);
         return(BadRequest(ex.Message));
     }
 }
 public IHttpActionResult Post([FromBody] Customer customer)
 {
     try
     {
         TimeUnit.Customers.Insert(customer);
         TimeUnit.Save();
         Utility.Log($"Insert data for customer with ID = {customer.Id}", "INFO");
         return(Ok(TimeFactory.Create(customer)));
     }
     catch (Exception ex)
     {
         Utility.Log(ex.Message, "ERROR", ex);
         return(BadRequest(ex.Message));
     }
 }
Exemple #23
0
 public IHttpActionResult Post([FromBody] Role role)
 {
     try
     {
         TimeUnit.Roles.Insert(role);
         TimeUnit.Save();
         Utility.Log($"Insert data for role {role.Name}", "INFO");
         return(Ok(TimeFactory.Create(role)));
     }
     catch (Exception ex)
     {
         Utility.Log(ex.Message, "ERROR", ex);
         return(BadRequest(ex.Message));
     }
 }
Exemple #24
0
 public IHttpActionResult Post([FromBody] Team team)
 {
     try
     {
         TimeUnit.Teams.Insert(team);
         TimeUnit.Save();
         Utility.Log($"Insert data for team {team.Name}", "INFO");
         return(Ok(TimeFactory.Create(team)));
     }
     catch (Exception ex)
     {
         Utility.Log(ex.Message, "ERROR", ex);
         return(BadRequest(ex.Message));
     }
 }
 public IHttpActionResult Post([FromBody] Employee employee)
 {
     try
     {
         employee.Position = TimeUnit.Roles.Get(employee.Position.Id);
         employee.Image    = employee.ConvertAndSave();
         TimeUnit.Employees.Insert(employee);
         TimeUnit.Save();
         Utility.Log($"Insert data for employee {employee.FullName}", "INFO");
         return(Ok(TimeFactory.Create(employee)));
     }
     catch (Exception ex)
     {
         Utility.Log(ex.Message, "ERROR", ex);
         return(BadRequest(ex.Message));
     }
 }
Exemple #26
0
 public IHttpActionResult Post([FromBody] Assignment assignment)
 {
     try
     {
         assignment.Day     = TimeUnit.Days.Get(assignment.Day.Id);
         assignment.Project = TimeUnit.Projects.Get(assignment.Project.Id);
         TimeUnit.Assignments.Insert(assignment);
         TimeUnit.Save();
         Utility.Log($"Insert data for ASSIGNMENT {assignment.Description}", "INFO");
         return(Ok(TimeFactory.Create(assignment)));
     }
     catch (Exception ex)
     {
         Utility.Log(ex.Message, "ERROR", ex);
         return(BadRequest(ex.Message));
     }
 }
Exemple #27
0
 public IHttpActionResult Post([FromBody] Project project)
 {
     try
     {
         project.Customer = TimeUnit.Customers.Get(project.Customer.Id);
         project.Team     = TimeUnit.Teams.Get(project.Team.Id);
         TimeUnit.Projects.Insert(project);
         TimeUnit.Save();
         Utility.Log($"Insert data for project {project.Name}", "INFO");
         return(Ok(TimeFactory.Create(project)));
     }
     catch (Exception ex)
     {
         Utility.Log(ex.Message, "ERROR", ex);
         return(BadRequest(ex.Message));
     }
 }
Exemple #28
0
        public IHttpActionResult Put([FromBody] Employee employee, int id)
        {
            try
            {
                if (TimeUnit.Employees.Get(id) == null)
                {
                    Utility.Log($"Update employee failed. Wrong id.", "ERROR");
                    return(NotFound());
                }

                var errors = employee.Validate();

                if (errors.Count > 0)
                {
                    string combindedString = string.Join(" ", errors.ToArray());
                    return(BadRequest(combindedString));
                }

                Employee oldEmployee = TimeUnit.Employees.Get(id);
                if (oldEmployee == null)
                {
                    return(NotFound());
                }
                employee          = FillEmployeeWithOldData(employee, oldEmployee);
                employee.Position = TimeUnit.Roles.Get(employee.Position.Id);

                //id = TimeUnit.Employees.Get().Where(x => x.Id == id).Select(x => x.Id).FirstOrDefault();
                if (TimeUnit.Employees.Get(id) == null)
                {
                    return(NotFound());
                }

                employee.Image = employee.ConvertAndSave();

                TimeUnit.Employees.Update(employee, id);
                TimeUnit.Save();
                Utility.Log($"Updated employee with id " + id + ".", "INFO");
                return(Ok(TimeFactory.Create(employee)));
            }
            catch (Exception ex)
            {
                Utility.Log($"Update employee failed.", "ERROR");
                return(BadRequest(ex.Message));
            }
        }
Exemple #29
0
        /// <summary>
        /// Delete Task by Id.
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        /// <response code="200">Returns the newly-created item</response>
        /// <response code="400">If the item is null</response>

        public IHttpActionResult Delete(int id)
        {
            try
            {
                Task task = TimeUnit.Tasks.Get(id);
                if (task == null)
                {
                    return(NotFound());
                }
                TimeUnit.Tasks.Delete(task);
                TimeUnit.Save();
                Utility.Log($"ROLE CONTROLLER: Deleted Called on Role, Successfully deleted id: {id}.", "INFO");
                return(Ok());
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Exemple #30
0
        /// <summary>
        /// Delete Customer by Id.
        /// </summary>
        /// <param name = "id"></param>
        /// <returns></returns>
        /// <response code="200">Returns the newly-created item</response>
        /// <response code="400">If the item is null</response>

        public IHttpActionResult Delete(int id)
        {
            try
            {
                Customer customer = TimeUnit.Customers.Get(id);
                if (customer == null)
                {
                    return(NotFound());
                }
                TimeUnit.Customers.Delete(customer);
                TimeUnit.Save();
                Utility.Log($"CUSTOMER CONTROLLER: Deleted Called on Customer, Successfully deleted id: {id}.", "INFO");
                return(Ok());
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }