// GET: Admin/Adopt/Delete

        public ActionResult Delete(int id)
        {
            Adopt adopt = db.Adopts
                          .Include("Gender")
                          .Include("PetSize")
                          .Include("AgeType")
                          .Include("SlideAdopts")
                          .FirstOrDefault(p => p.Id == id);

            if (adopt == null)
            {
                return(HttpNotFound());
            }
            foreach (var item in db.SlideAdopts.ToList())
            {
                if (item.AdoptId == id)
                {
                    string imagePath = Path.Combine(Server.MapPath("~/Uploads"), item.Image);

                    System.IO.File.Delete(imagePath);
                    db.SlideAdopts.Remove(item);
                }
            }
            foreach (var item1 in db.Appointments.ToList())
            {
                if (item1.AdoptId == id)
                {
                    db.Appointments.Remove(item1);
                }
            }
            db.Adopts.Remove(adopt);
            db.SaveChanges();

            return(RedirectToAction("Index"));
        }
Beispiel #2
0
        public IExecutable InterpretateCommand(string[] data)
        {
            IExecutable command = null;

            string commandName = data[0];

            string[] commandParams = data.Skip(1).ToArray();

            switch (commandName)
            {
            case "RegisterCleansingCenter":
                command = new RegisterCleansingCenter(commandParams, this.Databse);
                break;

            case "RegisterAdoptionCenter":
                command = new RegisterAdoptionCenter(commandParams, this.Databse);
                break;

            case "RegisterCastrationCenter":
                command = new RegisterCastratingCenter(commandParams, this.Databse);
                break;

            case "RegisterDog":
                command = new RegisterDog(commandParams, this.Databse, this.AnimalFactory);
                break;

            case "RegisterCat":
                command = new RegisterCat(commandParams, this.Databse, this.AnimalFactory);
                break;

            case "SendForCleansing":
                command = new SendForCleansing(commandParams, this.Databse);
                break;

            case "SendForCastration":
                command = new SendForCastrating(commandParams, this.Databse);
                break;

            case "Cleanse":
                command = new Cleanse(commandParams, this.Databse);
                break;

            case "Castrate":
                command = new Castrate(commandParams, this.Databse);
                break;

            case "Adopt":
                command = new Adopt(commandParams, this.Databse);
                break;

            case "CastrationStatistics":
                command = new CastrationStatistics(commandParams, this.Databse, this.writer);
                break;

            case "Paw Paw Pawah":
                command = new PawPawPawah(commandParams, this.Databse, this.Writer);
                break;
            }
            return(command);
        }
Beispiel #3
0
        public void updateAdoptTotal(int activityid)
        {
            Adopt adopt = (from p in db.Adopt where p.ActivityID == activityid select p).FirstOrDefault();

            adopt.Total = adopt.Total - 1;
            db.Configuration.ValidateOnSaveEnabled = false;
            db.SaveChanges();
            db.Configuration.ValidateOnSaveEnabled = true;
        }
        public ActionResult Update(Adopt adopt)
        {
            if (ModelState.IsValid)
            {
                Adopt Adopt = db.Adopts.Include("SlideAdopts").FirstOrDefault(p => p.Id == adopt.Id);
                if (adopt.ImageFile.Length > 1)
                {
                    foreach (SlideAdopt item in Adopt.SlideAdopts.ToList())
                    {
                        string oldImagePath = Path.Combine(Server.MapPath("~/Uploads/"), item.Image);
                        System.IO.File.Delete(oldImagePath);

                        db.SlideAdopts.Remove(item);
                        db.SaveChanges();
                    }

                    foreach (HttpPostedFileBase image in adopt.ImageFile)
                    {
                        string imageName = DateTime.Now.ToString("ddMMyyyyHHmmssffff") + image.FileName;
                        string imagePath = Path.Combine(Server.MapPath("~/Uploads"), imageName);

                        image.SaveAs(imagePath);
                        SlideAdopt slideAdopt = new SlideAdopt();
                        slideAdopt.Image   = imageName;
                        slideAdopt.AdoptId = adopt.Id;

                        db.SlideAdopts.Add(slideAdopt);
                        db.SaveChanges();
                    }
                }
                Adopt.Address    = adopt.Address;
                Adopt.Name       = adopt.Name;
                Adopt.Neutered   = adopt.Neutered;
                Adopt.Age        = adopt.Age;
                Adopt.Breed      = adopt.Breed;
                Adopt.Vaccinated = adopt.Vaccinated;
                Adopt.GenderId   = adopt.GenderId;
                Adopt.PetSizeId  = adopt.PetSizeId;
                Adopt.AgeTypeId  = adopt.AgeTypeId;

                db.Entry(Adopt).State = EntityState.Modified;
                db.Entry(Adopt).Property(c => c.CreatedDate).IsModified = false;
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }
            ViewBag.Gender  = db.Genders.ToList();
            ViewBag.PetSize = db.PetSizes.ToList();
            ViewBag.AgeType = db.AgeTypes.ToList();

            return(View(adopt));
        }
Beispiel #5
0
        //Admin/Position/Update
        public ActionResult Update(int id)
        {
            Adopt adopt = db.Adopts.Find(id);

            if (adopt == null)
            {
                return(HttpNotFound());
            }
            ViewBag.Gender  = db.Genders.ToList();
            ViewBag.PetSize = db.PetSizes.ToList();
            ViewBag.AgeType = db.AgeTypes.ToList();
            return(View(adopt));
        }
        // GET: Admin/Adopt/Details

        public ActionResult Details(int id)
        {
            Adopt adopt = db.Adopts.Include("Gender")
                          .Include("PetSize")
                          .Include("AgeType")
                          .Include("SlideAdopts")
                          .FirstOrDefault(p => p.Id == id);

            if (adopt == null)
            {
                return(HttpNotFound());
            }
            return(View(adopt));
        }
        public ActionResult Create(Adopt adopt)
        {
            if (ModelState.IsValid)
            {
                Adopt Adopt = new Adopt();
                Adopt.Address    = adopt.Address;
                Adopt.Name       = adopt.Name;
                Adopt.Neutered   = adopt.Neutered;
                Adopt.Age        = adopt.Age;
                Adopt.Breed      = adopt.Breed;
                Adopt.Vaccinated = adopt.Vaccinated;
                Adopt.GenderId   = adopt.GenderId;
                Adopt.PetSizeId  = adopt.PetSizeId;
                Adopt.AgeTypeId  = adopt.AgeTypeId;

                Adopt.CreatedDate = DateTime.Now;

                db.Adopts.Add(Adopt);
                db.SaveChanges();

                foreach (HttpPostedFileBase image in adopt.ImageFile)
                {
                    string imageName = DateTime.Now.ToString("ddMMyyyyHHmmssffff") + image.FileName;
                    string imagePath = Path.Combine(Server.MapPath("~/Uploads"), imageName);

                    image.SaveAs(imagePath);//hə hə

                    SlideAdopt slideAdopt = new SlideAdopt();
                    slideAdopt.Image   = imageName;
                    slideAdopt.AdoptId = Adopt.Id;

                    db.SlideAdopts.Add(slideAdopt);
                    db.SaveChanges();
                }
                return(RedirectToAction("Index"));
            }
            ViewBag.Gender  = db.Genders.ToList();
            ViewBag.PetSize = db.PetSizes.ToList();
            ViewBag.AgeType = db.AgeTypes.ToList();

            return(View(adopt));
        }
Beispiel #8
0
 public ActionResult AddAdoptSucculentList()
 {
     string[] goodsid = Request.Params.GetValues("goodsid");
     string[] total   = Request.Params.GetValues("Total");
     string[] actid   = Request.Params.GetValues("actid");
     for (int i = 0; i < goodsid.Length; i++)
     {
         Adopt adopt = new Adopt();
         adopt.ActivityID = int.Parse(actid[i]);
         adopt.GoodsID    = int.Parse(goodsid[i]);
         adopt.Total      = int.Parse(total[i]);
         if (adoptmanager.InsertAdopt(adopt))
         {
         }
         else
         {
             break;
         }
     }
     return(Content("<script>alert('提交成功,感谢您的支持~');window.location='" + Url.Action("Index", "SucculentActivity") + "'</script>"));
 }
Beispiel #9
0
 public bool InsertAdopt(Adopt adopt)
 {
     db.Adopt.Add(adopt);
     return(db.SaveChanges() > 0);
 }
Beispiel #10
0
 public bool InsertAdopt(Adopt adopt)
 {
     return(iadopt.InsertAdopt(adopt));
 }