Exemplo n.º 1
0
        public IHttpActionResult PutCOBSecurityReview(int id, COBSecurityReview cOBSecurityReview)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != cOBSecurityReview.COBSecurityReviewID)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 2
0
        public IHttpActionResult PostCOBSecurityReview(COBSecurityReview cOBSecurityReview)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.COBSecurityReviews.Add(cOBSecurityReview);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = cOBSecurityReview.COBSecurityReviewID }, cOBSecurityReview));
        }
Exemplo n.º 3
0
        public IHttpActionResult DeleteCOBSecurityReview(int id)
        {
            COBSecurityReview cOBSecurityReview = db.COBSecurityReviews.Find(id);

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

            db.COBSecurityReviews.Remove(cOBSecurityReview);
            db.SaveChanges();

            return(Ok(cOBSecurityReview));
        }
Exemplo n.º 4
0
        public IHttpActionResult PostCOBSecurityReviewLight(COBSecurityReview_Light cOBSecurityReviewLight)
        {
            DateTime                       currentDate         = DateTime.Now;
            Nullable <DateTime>            nullableCurrentDate = currentDate;
            IQueryable <AssociatedAccount> accounts;

            if (cOBSecurityReviewLight.AssociatedAccountIDs != null)
            {
                accounts = db.AssociatedAccounts.Where(p => cOBSecurityReviewLight.AssociatedAccountIDs.Contains(p.AssociatedAccountID));
            }
            else
            {
                accounts = db.AssociatedAccounts.Where(p => p.UserID == cOBSecurityReviewLight.RevieweeID);
            }

            foreach (var reviewedAccount in accounts)
            {
                reviewedAccount.Verified = cOBSecurityReviewLight.Status.Equals("Approved") ? nullableCurrentDate : null;
            }

            COBSecurityReview cOBSecurityReview = new COBSecurityReview
            {
                RevieweeID        = cOBSecurityReviewLight.RevieweeID,
                Status            = cOBSecurityReviewLight.Status,
                StatusDescription = cOBSecurityReviewLight.StatusDescription,
                ReviewerID        = RequestContext.Principal.Identity.GetUserId(),
                Created           = currentDate
            };

            db.COBSecurityReviews.Add(cOBSecurityReview);
            db.SaveChanges();

            foreach (var reviewedAccount in accounts)
            {
                db.AssociatedAccountsCOBSecurityReviews.Add(new AssociatedAccountCOBSecurityReview
                {
                    AssociatedAccountID = reviewedAccount.AssociatedAccountID,
                    COBSecurityReviewID = cOBSecurityReview.COBSecurityReviewID
                });
            }
            db.SaveChanges();

            return(Ok(new COBSecurityReview_Deep
            {
                COBSecurityReview = cOBSecurityReview,
                AssociatedAccounts = accounts
            }));
        }