Esempio n. 1
0
        public ActionResult DeleteConfirmed(int id)
        {
            OfferMade offerMade = db.OfferMades.Find(id);

            db.OfferMades.Remove(offerMade);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 2
0
 // Apply Events
 private void ApplyEvent(OfferMade @event)
 {
     if (_offerIds == null)
     {
         _offerIds = new List <Guid>();
     }
     _offerIds.Add(@event.OfferId);
 }
Esempio n. 3
0
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            OfferMade offerMade = db.OfferMades.Find(id);

            if (offerMade == null)
            {
                return(HttpNotFound());
            }
            return(View(offerMade));
        }
        public ActionResult Choice(int id, string choice)
        {
            try
            {
                //Find method can take null value
                OfferMade     offerMade     = db.OfferMades.Find(id);
                OfferReceived offerReceived = db.OfferReceiveds.Find(id);

                if (offerMade == null)
                {
                    //var userName = offerReceived.CurrentUser;
                    offerReceived.Choice = "Deleted";
                    db.SaveChanges();
                    return(Json(new { status = "null" }, JsonRequestBehavior.AllowGet));
                }

                var offerMadeModel = db.OfferMades
                                     .Where(x => x.OfferMadeId == id)
                                     .Single();

                if (choice.Equals("Accepted"))
                {
                    offerMadeModel.Status = "Confirmed";
                }
                if (choice.Equals("Declined"))
                {
                    offerMadeModel.Status = "Declined";
                }

                var offerReceivedModel = db.OfferReceiveds
                                         .Where(x => x.OfferReceivedId == id)
                                         .Single();

                offerReceivedModel.Choice = choice;

                db.SaveChanges();
            }
            catch (Exception ex)
            {
                return(Json(new { status = "error", errorMessage = ex.Message }, JsonRequestBehavior.AllowGet));
            }

            return(Json(new { status = "success" }, JsonRequestBehavior.AllowGet));
        }
Esempio n. 5
0
        public ActionResult PostOffer(OfferViewModel model)
        {
            try
            {
                var offerMade = new OfferMade
                {
                    PostingId     = model.PostingId,
                    CurrentUser   = model.CurrentUser,
                    SelectedUser  = model.SelectedUser,
                    Country       = model.Country,
                    State         = model.State,
                    City          = model.City,
                    PokemonOwned  = model.PokemonOwned,
                    PokemonWanted = model.PokemonWanted,
                    //initialization
                    Status        = "Pending",
                    DateTimeValue = DateTime.UtcNow
                };

                var offerReceived = new OfferReceived
                {
                    CurrentUser   = model.CurrentUser,
                    SelectedUser  = model.SelectedUser,
                    Country       = model.Country,
                    State         = model.State,
                    City          = model.City,
                    PokemonOwned  = model.PokemonOwned,
                    PokemonWanted = model.PokemonWanted,
                    Comments      = model.Comments,
                    Choice        = model.Choice,
                    DateTimeValue = DateTime.UtcNow
                };

                db.OfferMades.Add(offerMade);
                db.OfferReceiveds.Add(offerReceived);
                db.SaveChanges();

                return(Json(new { status = "success" }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(new { status = "error", errorMessage = ex.Message }, JsonRequestBehavior.AllowGet));
            }
        }