예제 #1
0
        public static async Task <bool> UpdateThumb(HttpPostedFile postedFile, int id)
        {
            try
            {
                var details = (from a in db.surveys
                               from b in db.surveys_type
                               where a.surveys_type_id == b.id && a.id == id
                               select a).FirstOrDefault();
                if (details == null)
                {
                    return(false);
                }
                else
                {
                    string fullPath = await ImageServices.UploadThumbAsync(postedFile); //return url image

                    details.thumb = fullPath;
                    int check = await db.SaveChangesAsync();

                    if (check > 0)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            catch (Exception e)
            {
                return(false);
            }
        }