Beispiel #1
0
        public static async Task <bool> UpdateAvatar(HttpPostedFile postedFile, int id)
        {
            try
            {
                var details = (from a in db.accounts
                               from b in db.details
                               where a.id == b.account_id && a.id == id select b).FirstOrDefault();
                if (details == null)
                {
                    return(false);
                }
                else
                {
                    string fullPath = await ImageServices.UploadImageAsync(postedFile); //return url image

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

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