// GET: PetProfile/Edit/5
 public ActionResult Edit(int id)
 {
     using (PODBProjectEntities entities = new PODBProjectEntities())
     {
         return(View(entities.PetProfiles.Where(e => e.petId.Equals(id)).FirstOrDefault()));
     }
 }
예제 #2
0
 // GET: Announcement/Edit/5
 public ActionResult Edit(int id)
 {
     using (PODBProjectEntities entities = new PODBProjectEntities())
     {
         return(View(entities.Announcements.Where(e => e.announceId.Equals(id)).FirstOrDefault()));
     }
 }
예제 #3
0
        public String PostPhotoAnnouncement(HttpPostedFileBase file)
        {
            PODBProjectEntities entities = new PODBProjectEntities();
            String imagePath             = "";
            var    path = "";

            if (file != null)
            {
                if (file.ContentLength > 0)
                {
                    if (Path.GetExtension(file.FileName).ToLower() == ".jpg" ||
                        Path.GetExtension(file.FileName).ToLower() == ".png" ||
                        Path.GetExtension(file.FileName).ToLower() == ".jpeg")
                    {
                        imagePath = "/Content/images/Announcement/" + file.FileName;
                        path      = Path.Combine(HttpContext.Current.Server.MapPath("~/Content/images/Announcement/"), file.FileName);
                        file.SaveAs(path);
                        entities.Images.Add(new Image()
                        {
                            imagePath = imagePath,
                            imageType = "Announcement",
                        });
                        entities.SaveChanges();
                    }
                }
            }
            return(imagePath);
        }
        public ActionResult Edit(int id, PetProfile petProfile, HttpPostedFileBase file)
        {
            int imageid;
            PODBProjectEntities entities = new PODBProjectEntities();
            String userId = User.Identity.GetUserId();

            PostPhoto photo = new PostPhoto();
            String    path  = photo.PostPhotoPet(file);

            if (file != null)
            {
                imageid = entities.Images.Where(e => e.imagePath.Equals(path)).FirstOrDefault().imageID;
            }
            else
            {
                imageid = entities.Announcements.Where(e => e.announceId.Equals(id)).FirstOrDefault().imageID;
            }
            try
            {
                using (PODBProjectEntities edit = new PODBProjectEntities())
                {
                    petProfile.Id                = User.Identity.GetUserId();
                    petProfile.imageID           = 1;
                    edit.Entry(petProfile).State = EntityState.Modified;
                    edit.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            catch
            {
                return(View());
            }
        }
예제 #5
0
        public ActionResult EditDetail()
        {
            PODBProjectEntities db = new PODBProjectEntities();
            string id = User.Identity.GetUserId();

            return(View(db.PetOwnerProfiles.Where(e => e.Id.Equals(id)).FirstOrDefault()));
        }
예제 #6
0
        public ActionResult Create(Announcement announce, HttpPostedFileBase file)
        {
            PODBProjectEntities entities = new PODBProjectEntities();

            PostPhoto photo = new PostPhoto();
            String    path  = photo.PostPhotoAnnouncement(file);

            int ImageID = entities.Images.Where(e => e.imagePath.Equals(path)).FirstOrDefault().imageID;

            try
            {
                using (PODBProjectEntities announcement = new PODBProjectEntities())
                {
                    announce.Id           = User.Identity.GetUserId();
                    announce.announceDate = DateTime.Now;
                    announce.imageID      = ImageID;
                    entities.Announcements.Add(announce);
                    entities.SaveChanges();
                }
                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
예제 #7
0
 public ActionResult GetData()
 {
     using (PODBProjectEntities db = new PODBProjectEntities())
     {
         List <PetOwnerProfile> poList = db.PetOwnerProfiles.ToList <PetOwnerProfile>();
         return(Json(new { data = poList }, JsonRequestBehavior.AllowGet));
     }
 }
예제 #8
0
        public ActionResult EditDetail(PetOwnerProfile info, HttpPostedFileBase file, Image ImageModel)
        {
            int imageid;
            PODBProjectEntities entities = new PODBProjectEntities();
            String userId = User.Identity.GetUserId();

            PostPhoto photo = new PostPhoto();
            String    path  = photo.PostPhotoPetOwner(file);

            if (file != null)
            {
                imageid = entities.Images.Where(e => e.imagePath.Equals(path)).FirstOrDefault().imageID;
            }
            else
            {
                imageid = entities.PetOwnerProfiles.Where(e => e.Id.Equals(userId)).FirstOrDefault().imageID;
            }

            using (PODBProjectEntities image = new PODBProjectEntities())
            {
                ImageModel.imageID               = imageid;
                ImageModel.imagePath             = path;
                ImageModel.imageType             = "PetOwnerProfile";
                entities.Entry(ImageModel).State = EntityState.Modified;
                entities.SaveChanges();
            }

            using (entities)
            {
                var result = entities.PetOwnerProfiles.SingleOrDefault(e => e.Id == userId);
                if (result != null)
                {
                    if (info.subdivision == null)
                    {
                        info.subdivision = "none";
                    }
                    else
                    {
                    }
                    var user = new PetOwnerProfile()
                    {
                        Id            = userId,
                        fullName      = info.fullName,
                        gender        = info.gender,
                        street        = info.street,
                        subdivision   = info.subdivision,
                        barangay      = info.barangay,
                        contactNumber = info.contactNumber,
                        email         = entities.AspNetUsers.Where(e => e.Id.Equals(userId)).FirstOrDefault().Email,
                        registerDate  = entities.PetOwnerProfiles.Where(e => e.Id.Equals(userId)).FirstOrDefault().registerDate,
                        updateDate    = DateTime.Now,
                        imageID       = imageid
                    };
                    entities.SaveChanges();
                }
                return(RedirectToAction("ViewDetail", "Manage"));
            }
        }
예제 #9
0
 public ActionResult DeleteViolations(int id)
 {
     using (PODBProjectEntities entities = new PODBProjectEntities())
     {
         Violation emp = entities.Violations.Where(x => x.violationId == id).FirstOrDefault <Violation>();
         entities.Violations.Remove(emp);
         entities.SaveChanges();
         return(Json(new { success = true, message = "Deleted Successfully" }, JsonRequestBehavior.AllowGet));
     }
 }
예제 #10
0
 public ActionResult Delete(int id)
 {
     using (PODBProjectEntities db = new PODBProjectEntities())
     {
         PetOwnerProfile emp = db.PetOwnerProfiles.Where(x => x.profileId == id).FirstOrDefault <PetOwnerProfile>();
         db.PetOwnerProfiles.Remove(emp);
         db.SaveChanges();
         return(Json(new { success = true, message = "Deleted Successfully" }, JsonRequestBehavior.AllowGet));
     }
 }
예제 #11
0
        public async Task <ActionResult> Login(LoginViewModel model, string returnUrl)
        {
            var db = new PODBProjectEntities();

            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            // This doesn't count login failures towards account lockout
            // To enable password failures to trigger account lockout, change to shouldLockout: true,
            var result = await SignInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, shouldLockout : true);

            // If username and password is correct check if account is activated.
            String id = User.Identity.GetUserId();

            switch (result)
            {
            case SignInStatus.Success:
                var user = await UserManager.FindAsync(model.Email, model.Password);

                var roles = await UserManager.GetRolesAsync(user.Id);

                if (!db.AspNetUsers.Where(e => e.Email.Equals(model.Email)).FirstOrDefault().EmailConfirmed)
                {
                    Session.Abandon();
                    AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
                    ModelState.AddModelError("", "You need to confirm your email address");
                    return(RedirectToAction("ConfirmBeforeLogin", "Account"));
                }
                else if (roles.Contains("Admin"))
                {
                    return(RedirectToAction("Index", "Admin"));
                }
                else if (roles.Contains("Employee"))
                {
                    return(RedirectToAction("Index", "Employee"));
                }
                else
                {
                    return(RedirectToLocal(returnUrl));
                }

            case SignInStatus.LockedOut:
                return(View("Lockout"));

            case SignInStatus.RequiresVerification:
                return(RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = model.RememberMe }));

            case SignInStatus.Failure:
            default:
                ModelState.AddModelError("", "Invalid login attempt.");
                return(View(model));
            }
        }
예제 #12
0
        public ActionResult PetOwnerProfile()
        {
            PODBProjectEntities entities = new PODBProjectEntities();

            if (entities.PetOwnerProfiles.Where(e => e.Id.Equals(User.Identity.GetUserId())) != null)
            {
                return(View());
            }
            else
            {
                return(RedirectToAction("Index", "Manage"));
            }
        }
예제 #13
0
        public ActionResult ViewDetail()
        {
            PODBProjectEntities entities = new PODBProjectEntities();

            if (entities.PetOwnerProfiles.Where(e => e.Id.Equals(User.Identity.GetUserId())) == null)
            {
                return(RedirectToAction("PetOwnerProfile", "Account"));
            }
            else
            {
                string id = User.Identity.GetUserId();
                return(View(entities.PetOwnerProfiles.Where(e => e.Id.Equals(id)).FirstOrDefault()));
            }
        }
예제 #14
0
 public ActionResult AddOrEditReports(int id = 0)
 {
     if (id == 0)
     {
         return(View(new Report()));
     }
     else
     {
         using (PODBProjectEntities entities = new PODBProjectEntities())
         {
             return(View(entities.Violations.Where(x => x.violationId == id).FirstOrDefault <Violation>()));
         }
     }
 }
예제 #15
0
 public ActionResult AddOrEditAdoptions(int id = 0)
 {
     if (id == 0)
     {
         return(View(new Adoption()));
     }
     else
     {
         using (PODBProjectEntities entities = new PODBProjectEntities())
         {
             return(View(entities.Adoptions.Where(x => x.adoptionId == id).FirstOrDefault <Adoption>()));
         }
     }
 }
        // GET: PetProfile
        public ActionResult Index()
        {
            userId = User.Identity.GetUserId();
            PODBProjectEntities entities = new PODBProjectEntities();

            if ((entities.PetProfiles.Where(e => e.Id.Equals(userId)).FirstOrDefault() == null))
            {
                return(View("PetProfileNotFound"));
            }
            else
            {
                return(View(entities.PetProfiles.Where(e => e.Id.Equals(userId)).ToList()));
            }
        }
예제 #17
0
 public ActionResult AddOrEdit(int id = 0)
 {
     if (id == 0)
     {
         return(View(new PetOwnerProfile()));
     }
     else
     {
         using (PODBProjectEntities db = new PODBProjectEntities())
         {
             return(View(db.PetOwnerProfiles.Where(x => x.profileId == id).FirstOrDefault <PetOwnerProfile>()));
         }
     }
 }
예제 #18
0
        public ActionResult PetOwnerProfile(PetOwnerProfile info, HttpPostedFileBase file, Image ImageModel)
        {
            PODBProjectEntities entities = new PODBProjectEntities();
            String userId = User.Identity.GetUserId();

            PostPhoto photo = new PostPhoto();
            String    path  = photo.PostPhotoPetOwner(file);

            int    imageid = entities.Images.Where(e => e.imagePath.Equals(path)).FirstOrDefault().imageID;
            string Email   = entities.AspNetUsers.Where(e => e.Id.Equals(userId)).FirstOrDefault().Email;

            if (info.subdivision == null)
            {
                info.subdivision = "N/A";
            }
            else
            {
            }
            var user = new PetOwnerProfile()
            {
                Id            = userId,
                fullName      = info.fullName,
                gender        = info.gender,
                street        = info.street,
                subdivision   = info.subdivision,
                barangay      = info.barangay,
                contactNumber = info.contactNumber,
                email         = Email,
                registerDate  = DateTime.Now,
                updateDate    = DateTime.Now,
                imageID       = imageid
            };

            entities.PetOwnerProfiles.Add(user);
            entities.SaveChanges();

            if (!entities.AspNetUsers.Where(e => e.Email.Equals(Email)).FirstOrDefault().EmailConfirmed)
            {
                Session.Abandon();
                AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
                ModelState.AddModelError("", "You need to confirm your email address");
                return(RedirectToAction("ConfirmBeforeLogin", "Account"));
            }
            else
            {
                return(RedirectToAction("Index", "Home"));
            }
        }
 public ActionResult Delete(int id, FormCollection collection)
 {
     try
     {
         using (PODBProjectEntities entities = new PODBProjectEntities())
         {
             PetProfile petProfile = entities.PetProfiles.Where(e => e.petId.Equals(id)).FirstOrDefault();
             entities.PetProfiles.Remove(petProfile);
             entities.SaveChanges();
             return(RedirectToAction("Index"));
         }
     }
     catch
     {
         return(View());
     }
 }
예제 #20
0
        public ActionResult CreateAnnouncement(AnnouncementModel announce)
        {
            string UserID = User.Identity.GetUserId();
            PODBProjectEntities entities     = new PODBProjectEntities();
            Announcement        announcement = new Announcement()
            {
                announceTitle = announce.announceTitle,
                announceText  = announce.announceText,
                announceDate  = DateTime.Now,
                Id            = UserID,
                imageID       = 1
            };

            entities.Announcements.Add(announcement);
            entities.SaveChanges();
            return(View());
        }
예제 #21
0
        public ActionResult Delete(int id, Announcement announce)
        {
            PODBProjectEntities entities = new PODBProjectEntities();

            try
            {
                Announcement announcement = entities.Announcements.Find(id);
                entities.Announcements.Remove(announcement);
                entities.SaveChanges();

                return(RedirectToAction("Index"));
            }
            catch (NullReferenceException)
            {
                return(View());
            }
        }
예제 #22
0
 public ActionResult AddOrEditReports(Report report)
 {
     using (PODBProjectEntities entities = new PODBProjectEntities())
     {
         if (report.reportId == 0)
         {
             entities.Reports.Add(report);
             entities.SaveChanges();
             return(Json(new { success = true, message = "Saved Successfully" }, JsonRequestBehavior.AllowGet));
         }
         else
         {
             entities.Entry(report).State = EntityState.Modified;
             entities.SaveChanges();
             return(Json(new { success = true, message = "Updated Successfully" }, JsonRequestBehavior.AllowGet));
         }
     }
 }
예제 #23
0
 public ActionResult AddOrEditViolations(Violation violation)
 {
     using (PODBProjectEntities entities = new PODBProjectEntities())
     {
         if (violation.violationId == 0)
         {
             entities.Violations.Add(violation);
             entities.SaveChanges();
             return(Json(new { success = true, message = "Saved Successfully" }, JsonRequestBehavior.AllowGet));
         }
         else
         {
             entities.Entry(violation).State = EntityState.Modified;
             entities.SaveChanges();
             return(Json(new { success = true, message = "Updated Successfully" }, JsonRequestBehavior.AllowGet));
         }
     }
 }
예제 #24
0
 public ActionResult AddOrEdit(PetOwnerProfile po)
 {
     using (PODBProjectEntities db = new PODBProjectEntities())
     {
         if (po.profileId == 0)
         {
             db.PetOwnerProfiles.Add(po);
             db.SaveChanges();
             return(Json(new { success = true, message = "Saved Successfully" }, JsonRequestBehavior.AllowGet));
         }
         else
         {
             db.Entry(po).State = EntityState.Modified;
             db.SaveChanges();
             return(Json(new { success = true, message = "Updated Successfully" }, JsonRequestBehavior.AllowGet));
         }
     }
 }
        public ActionResult Create(PetProfileModel petProfile, HttpPostedFileBase file)
        {
            PODBProjectEntities entities = new PODBProjectEntities();
            PostPhoto           photo    = new PostPhoto();
            String path = photo.PostPhotoPet(file);

            int ImageID = entities.Images.Where(e => e.imagePath.Equals(path)).FirstOrDefault().imageID;

            if (petProfile.mChipId == null)
            {
                petProfile.mChipId = "Not Microchipped";
            }
            var pet = new PetProfile
            {
                Id           = User.Identity.GetUserId(),
                imageID      = ImageID,
                petName      = petProfile.petName,
                petType      = petProfile.petType,
                petBreed     = petProfile.petBreed,
                gender       = petProfile.gender,
                mChipId      = petProfile.mChipId,
                mChipStatus  = petProfile.mChipStatus,
                nueterStatus = petProfile.nueterStatus
            };

            entities.PetProfiles.Add(pet);
            try
            {
                entities.SaveChanges();
            }
            catch (DbEntityValidationException ex)
            {
                foreach (var entityValidationErrors in ex.EntityValidationErrors)
                {
                    foreach (var validationError in entityValidationErrors.ValidationErrors)
                    {
                        Response.Write("Property: " + validationError.PropertyName + " Error: " + validationError.ErrorMessage);
                    }
                }
            }
            return(RedirectToAction("Index"));
        }
예제 #26
0
 public RecordsController()
 {
     entities = new PODBProjectEntities();
 }
예제 #27
0
        public ActionResult Index()
        {
            var db = new PODBProjectEntities();

            return(View(db.Announcements));
        }
예제 #28
0
        // GET: Announcement
        public ActionResult Index()
        {
            PODBProjectEntities entities = new PODBProjectEntities();

            return(View(entities.Announcements.ToList()));
        }