Agribusiness.Web.Controllers.PublicController.GetPublicThumbnail C# (CSharp) Метод

GetPublicThumbnail() публичный Метод

public GetPublicThumbnail ( int id ) : System.Web.Mvc.ActionResult
id int
Результат System.Web.Mvc.ActionResult
        public ActionResult GetPublicThumbnail(int? id)
        {
            if(id != null)
            {
                var person = Repository.OfType<Person>().GetById(id.Value);

                if (person.MainProfilePicture != null)
                    return File(person.ThumbnailPicture, person.ContentType ?? "image/png");

                // check to make sure it is ok
                // for now only committee members can be downloaded from this action
                var committeeRole = Repository.OfType<SeminarRole>().Queryable.Where(a => a.Id == StaticIndexes.Role_SteeringCommittee).FirstOrDefault();
                var isCommitteeMember = Repository.OfType<SeminarPerson>().Queryable.Where(a => a.SeminarRoles.Contains(committeeRole) && a.Person == person).Any();

                // not authorized to release this person's image
                if (!isCommitteeMember)
                    return File(new byte[0], string.Empty);
            }
            // load the default image
            var fs = new FileStream(Server.MapPath("~/Images/profileplaceholder_thumb.png"), FileMode.Open, FileAccess.Read);
            var img = new byte[fs.Length];
            fs.Read(img, 0, img.Length);
            fs.Close();

            return File(img, "image/png");
        }