Exemplo n.º 1
0
        public HttpResponseMessage Delete(HttpRequestMessage request, int id)
        {
            var card = new Card();

            card.Remove(id);

            return request.CreateResponse(HttpStatusCode.NoContent);
        }
Exemplo n.º 2
0
        public HttpResponseMessage Add(HttpRequestMessage request, Card card)
        {
            var result = card.Add(card.Name, card.Description, card.AssignedTo, card.AreaID, card.TfsID);

            if (result != null)
            {
                return request.CreateResponse(HttpStatusCode.Created, result);
            }
            else
            {
                return request.CreateResponse(HttpStatusCode.InternalServerError);
            }
        }
Exemplo n.º 3
0
        public HttpResponseMessage Edit(HttpRequestMessage request, int id, Area area)
        {
            Card card = new Card();

            var result = card.Move(id, area);

            if (result != null)
            {
                return request.CreateResponse(HttpStatusCode.OK, result);
            }
            else
            {
                return request.CreateResponse(HttpStatusCode.InternalServerError);
            }
        }
Exemplo n.º 4
0
        public HttpResponseMessage Edit(HttpRequestMessage request, int id, Card card)
        {
            card.ID = id;

            var result = card.Update(card);

            if (result != null)
            {
                return request.CreateResponse(HttpStatusCode.OK, result);
            }
            else
            {
                return request.CreateResponse(HttpStatusCode.InternalServerError);
            }
        }
Exemplo n.º 5
0
        public HttpResponseMessage ImportFromTFSID(HttpRequestMessage request, int tfsWorkItem, int areaID)
        {
            WorkItem workItem = new WorkItem();

            var tfsItem = new List<WorkItem>() { workItem.Get(tfsWorkItem) };

            var result = new Card().Add(tfsItem, areaID);

            if (result != null)
            {
                return request.CreateResponse(HttpStatusCode.Accepted, result);
            }

            return request.CreateResponse(HttpStatusCode.InternalServerError);
        }
        public Card Add(Card card)
        {
            using (var db = new CardsDBContext())
            {
                if (card.TfsID != 0 && db.Cards.FirstOrDefault(item => item.TfsID == card.TfsID) != null)
                {
                    return null;
                }

                var result = db.Cards.Add(card);
                db.SaveChanges();

                return result;
            }
        }
Exemplo n.º 7
0
        public HttpResponseMessage ImportFromSavedTFSQuery(HttpRequestMessage request, string queryName, int areaID)
        {
            WorkItem workItem = new WorkItem();
            Card card = new Card();

            var tfsItems = workItem.Get(queryName);

            List<Card> result = card.Add(tfsItems, areaID);

            if (result != null)
            {
                return request.CreateResponse(HttpStatusCode.Accepted, result);
            }

            return request.CreateResponse(HttpStatusCode.InternalServerError);
        }
Exemplo n.º 8
0
        public HttpResponseMessage GetByID(HttpRequestMessage request, int id)
        {
            var card = new Card();

            var result = card.Get(id);

            return request.CreateResponse(HttpStatusCode.OK, result);
        }
Exemplo n.º 9
0
        public HttpResponseMessage GetAll(HttpRequestMessage request, int areaID)
        {
            var card = new Card();

            var result = card.GetAll(areaID);

            return request.CreateResponse(HttpStatusCode.OK, result);
        }
Exemplo n.º 10
0
        private Card onUpdate(Card card, CardActivityType cardActivityType)
        {
            var dateNow = DateProvider.Now();

            card.ModifiedDate = dateNow;
            card.ModifiedUser = IdentityProvider.GetUserName();

            var cardResult = StorageProvider.Update(card);

            if (cardResult != null)
            {
                CardActivity cardActivity = new CardActivity(StorageProvider, IdentityProvider);

                cardResult.CardActivities.Add(cardActivity.Add(card.ID, cardActivityType, dateNow));
            }

            return cardResult;
        }
Exemplo n.º 11
0
 /// <summary>
 /// Updates the specified card.
 /// </summary>
 /// <param name="card">The card.</param>
 /// <returns></returns>
 public Card Update(Card card)
 {
     if (card != null)
     {
         return onUpdate(card, CardActivityType.Modify);
     }
     else
     {
         return null;
     }
 }
Exemplo n.º 12
0
        /// <summary>
        /// Adds the specified name.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="description">The description.</param>
        /// <param name="assignedTo">The assigned to.</param>
        /// <param name="areaID">The area identifier.</param>
        /// <param name="tfsID">The TFS identifier.</param>
        /// <returns></returns>
        public Card Add(string name, string description, string assignedTo, int areaID, int tfsID)
        {
            var dateNow     = DateProvider.Now();
            var currentUser = IdentityProvider.GetUserName();

            var card = new Card()
            {
                CreatedUser = currentUser,
                CreatedDate = dateNow,
                ModifiedUser = currentUser,
                ModifiedDate = dateNow,

                Name        = name,
                Description = description,
                AreaID      = areaID,
                TfsID       = tfsID,
                AssignedTo  = assignedTo
            };

            var result = StorageProvider.Add(card);

            if (result != null)
            {
                CardActivity activity = new CardActivity(StorageProvider, IdentityProvider);
                activity = activity.Add(result.ID, CardActivityType.Add, dateNow);

                result.CardActivities.Add(activity);
            }

            return result;
        }
        public Card Update(Card card)
        {
            using (var db = new CardsDBContext())
            {
                var cardToUpdate = db.Cards.FirstOrDefault(item => item.ID == card.ID);

                if (cardToUpdate != null)
                {
                    cardToUpdate.Name         = card.Name;
                    cardToUpdate.Description  = card.Description;
                    cardToUpdate.TfsID        = card.TfsID;
                    cardToUpdate.AreaID       = card.AreaID;
                    cardToUpdate.ModifiedDate = card.ModifiedDate;
                    cardToUpdate.ModifiedUser = card.ModifiedUser;
                    cardToUpdate.AssignedTo   = card.AssignedTo;

                    db.SaveChanges();

                    return cardToUpdate;
                }
                else
                {
                    return null;
                }
            }
        }
        public void RemoveCard(Card card)
        {
            using (var db = new CardsDBContext())
            {
                var cardToUpdate = db.Cards.FirstOrDefault(item => item.ID == card.ID);

                if (cardToUpdate != null)
                {
                    cardToUpdate.ModifiedDate = card.ModifiedDate;
                    cardToUpdate.ModifiedUser = card.ModifiedUser;
                    cardToUpdate.Active = false;

                    db.SaveChanges();
                }
            }
        }