Пример #1
0
        public async Task <IHttpActionResult> EditProfilePicture(int userID, int mediaID, string path)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (string.IsNullOrWhiteSpace(path))
            {
                return(BadRequest());
            }

            if (!(await db.Users.Select(u => u.UserID == userID).FirstOrDefaultAsync()))
            {
                return(NotFound());
            }

            User user = await Task.Run(() => db.Users.Where((u) => u.UserID == userID).FirstOrDefault());

            if (user == null)
            {
                return(BadRequest());
            }

            await db.SetAnImage(userID,
                                mediaID,
                                null,
                                path);

            return(Ok());
        }