public IHttpActionResult PutPetOwnerProfile(int id, PetOwnerProfile petOwnerProfile)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != petOwnerProfile.profileId)
            {
                return(BadRequest());
            }

            db.Entry(petOwnerProfile).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PetOwnerProfileExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        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());
            }
        }
예제 #3
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"));
            }
        }
예제 #4
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));
         }
     }
 }
예제 #5
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));
         }
     }
 }
예제 #6
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));
         }
     }
 }