Ejemplo n.º 1
0
        public ActionResult Delete(int id = 0)
        {
            BookstoreContext db = new BookstoreContext();
               Posting post = db.Postings.Find(id);
               if (post == null)
               {
               post = new Posting();
               }
               try
               {
               OfficialPosting opost = db.OfficialPostings.Find(id);
               if (opost != null)
               {
                   db.OfficialPostings.Remove(opost);
               }

               db.Postings.Remove(post);
               db.SaveChanges();
               }
               catch (Exception e)
               {

               }
               //Add Audit
               var userIds = WebSecurity.GetUserId(User.Identity.Name);
               var postId = id;
               AuditController.AuditEntry(userIds, postId, AuditController.REMOVEOFFICIAL);
               return RedirectToAction("Manage", "manage");
        }
Ejemplo n.º 2
0
        /*
         *  METHOD      : AuditEntry
         *  DESCRIPTION :
         *      When modifying a Posting, this method compares the two
         *      and records the differences.  Specifically, the user attributes.
         *  PARAMETERS  :
         *      int userId           : user logged in
         *      Employee oldPost : Post being modified
         *      Employee newPost : "new" Post (being modified)
         *      int originInstitutionID  : The Institution ID the old post belonged to
         *  RETURNS     : N/A
         */
        public static void AuditEntry(int userId, Posting oldPost, Posting newPost)
        {
            using (var context = new BookstoreContext())
            {

                if (oldPost != null && newPost != null)
                {
                    // general post's attributes
                    if (oldPost.author != newPost.author)
                    {
                        AuditEntry(userId, newPost.PostingID, MODIFY, "AUTHOR", oldPost.author, newPost.author);
                    }
                    if (oldPost.BookTitle != newPost.BookTitle)
                    {
                        AuditEntry(userId, newPost.PostingID, MODIFY, "BOOK TITLE", oldPost.BookTitle, newPost.BookTitle);
                    }
                    if (oldPost.PostTitle!= newPost.PostTitle)
                    {
                        AuditEntry(userId, newPost.PostingID, MODIFY, "POST TILTE", oldPost.PostTitle, newPost.PostTitle);
                    }
                    if (oldPost.PostDescription != newPost.PostDescription)
                    {
                        AuditEntry(userId, newPost.PostingID, MODIFY, "POST DESCRIPTION", oldPost.PostDescription, newPost.PostDescription);
                    }
                    if (oldPost.price != newPost.price)
                    {
                        AuditEntry(userId, newPost.PostingID, MODIFY, "PRICE", oldPost.price.ToString(), newPost.price.ToString());
                    }
                }

            }
        }
Ejemplo n.º 3
0
 public ActionResult Details(int id = 0)
 {
     Posting post = db.Postings.Find(id);
     if (post == null)
     {
         post = new Posting();
     }
     return View(post);
 }
Ejemplo n.º 4
0
 public ActionResult Edit(int id = 0)
 {
     Posting post = db.Postings.Find(id);
     if (post == null)
     {
         post = new Posting();
     }
     var postingViewModel = new PostingsViewModel { PostingType = "NORMAL" };
     postingViewModel.postings = post;
     return View(postingViewModel);
 }
Ejemplo n.º 5
0
 public ActionResult EditOfficialBook(int id = 0)
 {
     Posting post = db.Postings.Find(id);
        if (post == null)
        {
        post = new Posting();
        }
        OfficialPosting Opost = db.OfficialPostings.Find(id);
        if (Opost == null)
        {
        Opost = new OfficialPosting();
        }
        var postingViewModel = new PostingsViewModel { PostingType = "OFFICIAL" };
        postingViewModel.Opostings = Opost;
        postingViewModel.postings = post;
        return View(postingViewModel);
 }
Ejemplo n.º 6
0
        public ActionResult OfficialBook(int id = 0)
        {
            BookstoreContext dba = new BookstoreContext();
            Posting post = dba.Postings.Find(id);
            if (post == null)
            {
                post = new Posting();
            }

            var manageViewModel = new ManageViewModel();
            manageViewModel.postings = post;
            return View(manageViewModel);
        }
Ejemplo n.º 7
0
        public ActionResult PostPreview2(Posting post)
        {
            if (post == null)
                post = new Posting();

            return View(post);
            // return View();
        }