Exemplo n.º 1
0
      public IHttpActionResult PostWorkAllocation(WorkAllocation workAllocation)
      {
          if (!ModelState.IsValid)
          {
              return(BadRequest(ModelState));
          }

          db.WorkAllocations.Add(workAllocation);

          try
          {
              db.SaveChanges();
          }
          catch (DbUpdateException)
          {
              if (WorkAllocationExists(workAllocation.TeamID))
              {
                  return(Conflict());
              }
              else
              {
                  throw;
              }
          }

          return(CreatedAtRoute("DefaultApi", new { id = workAllocation.TeamID }, workAllocation));
      }
Exemplo n.º 2
0
      public IHttpActionResult PutWorkAllocation(int id, WorkAllocation workAllocation)
      {
          if (!ModelState.IsValid)
          {
              return(BadRequest(ModelState));
          }

          if (id != workAllocation.TeamID)
          {
              return(BadRequest());
          }

          db.Entry(workAllocation).State = EntityState.Modified;

          try
          {
              db.SaveChanges();
          }
          catch (DbUpdateConcurrencyException)
          {
              if (!WorkAllocationExists(id))
              {
                  return(NotFound());
              }
              else
              {
                  throw;
              }
          }

          return(StatusCode(HttpStatusCode.NoContent));
      }
Exemplo n.º 3
0
      public IHttpActionResult GetWorkAllocation(int workId, int userId)
      {
          WorkAllocation workAllocation = db.WorkAllocations.Find(workId, userId);

          if (workAllocation == null)
          {
              return(NotFound());
          }

          return(Ok(workAllocation));
      }
Exemplo n.º 4
0
        public async Task <bool> AddWork(WorkAllocation _work)
        {
            ResponseMessage = await client.PostAsJsonAsync("Work/AddWork", _work);

            if (ResponseMessage.IsSuccessStatusCode)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 5
0
      public IHttpActionResult DeleteWorkAllocation(int id, int team)
      {
          WorkAllocation workAllocation = db.WorkAllocations.Find(id);

          if (workAllocation == null)
          {
              return(NotFound());
          }

          db.WorkAllocations.Remove(workAllocation);
          db.SaveChanges();

          return(Ok(workAllocation));
      }