public async Task <IActionResult> SaveProject(SaveProjectViewModel project)
        {
            var user = await GetCurrentUserAsync();

            if (!ModelState.IsValid)
            {
                return(NotFound());
            }
            if (project.Title != null)
            {
                var p = _context.Project.SingleOrDefault(v => v.Title == null && v.User == user);
                p.Title = project.Title;
                _context.Project.Update(p);

                foreach (var item in project.ProjectClass)
                {
                    var projects = _context.ProjectVideos.SingleOrDefault(pv => pv.ProjectVideosId == item.ProjectVideosId);
                    projects.XPosition = item.XPosition;
                    projects.YPosition = item.YPosition;
                    projects.Width     = item.Width;
                    projects.Height    = item.Height;
                    projects.Rotation  = item.Rotation;
                    _context.ProjectVideos.Update(projects);
                }
                await _context.SaveChangesAsync();
            }
            return(Ok(new { response = "Go baby go" }));
        }
Example #2
0
        public async Task <IActionResult> PutAsync([FromBody] SaveProjectViewModel spvm)
        {
            AuthenticatedInfo authInfo = await this.ResolveAuthenticatedEntitiesAsync(db, userManager);

            var res = await projectManager.UpdateAsync(spvm, authInfo.UserId, new UserProvider(userManager));

            if (!res.Success)
            {
                return(BadRequest(res.Errors));
            }

            return(Ok());
        }