Ejemplo n.º 1
0
        // GET:/PetLostFound/ClaimProcess/
        // Claim back one's pet
        public ActionResult ClaimProcess(int serviceId = 0)
        {
            int petId = 0;
            var cUser = (Customer)Session["currentUser"];
            Transaction trans = new Transaction();

            trans.CustomerId = cUser.CustomerId;
            trans.ServiceId = serviceId;
            trans.Date = System.DateTime.Now;
            trans.Status = "Pet claim initiated";

            if (ModelState.IsValid)
            {
                db.Transactions.Add(trans);
                db.SaveChanges();
            }

            var getPetId = (from service in db.Services
                            where service.ServiceId.Equals(serviceId)
                            select new { service.PetId });

            foreach (var c in getPetId)
            {
                petId = (int)c.PetId;
            }

            Pet thePet = new Pet();
            thePet = db.Pets.Find(petId);
            thePet.TransactionId = trans.TransactionId;

            if (ModelState.IsValid)
            {
                db.Entry(thePet).State = EntityState.Modified;
                db.SaveChanges();
            }

            return View();
        }
Ejemplo n.º 2
0
        public ActionResult HireProcess(int serviceId = 0)
        {
            //Service theService = db.Services.Find(serviceId);
            var cUser = (Customer)Session["currentUser"];
            Transaction trans = new Transaction();

            trans.CustomerId = cUser.CustomerId;
            trans.ServiceId = serviceId;
            trans.Date = System.DateTime.Now;
            trans.Status = "Finished";

            //Pet pet = db.Pet.Find(id);

            if (ModelState.IsValid)
            {
                db.Transactions.Add(trans);
                db.SaveChanges();
                //return RedirectToAction("Index");
            }

            return View();
        }
Ejemplo n.º 3
0
        public ActionResult BuyProcess(int serviceId = 0)
        {
            int petId = 0;
            var cUser = (Customer)Session["currentUser"];
            Transaction trans = new Transaction();

            trans.CustomerId = cUser.CustomerId;
            trans.ServiceId = serviceId;
            trans.Date = System.DateTime.Now;
            trans.Status = "Finished";

            if (ModelState.IsValid)
            {
                db.Transactions.Add(trans);
                db.SaveChanges();
                //return RedirectToAction("Index");
            }

            /* Service theService = db.Services.Find(serviceId);
             db.Services.Remove(theService);
             db.SaveChanges();*/

            var getPetId = (from service in db.Services
                            where service.ServiceId.Equals(serviceId)
                            select new { service.PetId });

            foreach (var c in getPetId)
            {
                petId = (int)c.PetId;
            }

            Pet thePet = new Pet();
            thePet = db.Pets.Find(petId);
            thePet.TransactionId = trans.TransactionId;

            if (ModelState.IsValid)
            {
                db.Entry(thePet).State = EntityState.Modified;
                db.SaveChanges();
            }

            /*
            if (pet == null)
            {
                return HttpNotFound();
            }
            return View(pet);*/
            return View();
        }