public ActionResult VolunteerApprovals(VolunteerModel m)
 {
     m.Populate(m.PeopleId);
     return View("Ministry/Volunteer", m);
 }
        public ActionResult Upload(int id, HttpPostedFileBase file)
        {
            if (file == null)
                return Content("no file");

            var vol = new VolunteerModel(id);
            var name = System.IO.Path.GetFileName(file.FileName);

            var f = new VolunteerForm
            {
                UploaderId = Util.UserId1,
                PeopleId = vol.Volunteer.PeopleId,
                Name = name.Truncate(100),
                AppDate = Util.Now,
            };

            var bits = new byte[file.ContentLength];
            file.InputStream.Read(bits, 0, bits.Length);

            var mimetype = file.ContentType.ToLower();

            switch (mimetype)
            {
                case "image/jpeg":
                case "image/pjpeg":
                case "image/gif":
                case "image/png":
                {
                    f.IsDocument = false;

                    try
                    {
                        f.SmallId = ImageData.Image.NewImageFromBits(bits, 165, 220).Id;
                        f.MediumId = ImageData.Image.NewImageFromBits(bits, 675, 900).Id;
                        f.LargeId = ImageData.Image.NewImageFromBits(bits).Id;
                    }
                    catch
                    {
                        return View("Index", vol);
                    }

                    break;
                }

                case "text/plain":
                case "application/pdf":
                case "application/msword":
                case "application/vnd.ms-excel":
                {
                    f.MediumId = ImageData.Image.NewImageFromBits(bits, mimetype).Id;
                    f.SmallId = f.MediumId;
                    f.LargeId = f.MediumId;
                    f.IsDocument = true;
                    break;
                }

                default: return View("Index", vol);
            }

            DbUtil.Db.VolunteerForms.InsertOnSubmit(f);
            DbUtil.Db.SubmitChanges();
            DbUtil.LogActivity($"Uploading VolunteerApp for {vol.Volunteer.Person.Name}");

            return Redirect($"/Volunteering/{vol.Volunteer.PeopleId}#tab_documents");
        }
 public ActionResult Edit(int id)
 {
     var vol = new VolunteerModel(id);
     return View(vol);
 }
 public ActionResult Update(int id, VolunteerModel m)
 {
     m.Update(id);
     return View("Display", m);
 }