public IHttpActionResult DeleteWall(int wallId) { if (wallId <= 0) { return(BadRequest()); } try { _wallService.DeleteWall(wallId, GetUserAndOrganization(), EntityModels.Models.Multiwall.WallType.UserCreated); return(Ok()); } catch (ValidationException e) { return(BadRequestWithError(e)); } catch (UnauthorizedException) { return(Unauthorized()); } }
public async Task Delete(int id, UserAndOrganizationDTO userOrg) { var project = await _projectsDbSet .Include(p => p.Members) .Include(p => p.Wall.Members) .Include(p => p.Wall.Moderators) .Include(p => p.Attributes) .FirstOrDefaultAsync(p => p.Id == id && p.OrganizationId == userOrg.OrganizationId); if (project == null) { throw new ValidationException(ErrorCodes.ContentDoesNotExist, "Project not found"); } ValidateOwnershipPermissions(project.OwnerId, userOrg); _projectsDbSet.Remove(project); _wallService.DeleteWall(project.WallId, userOrg, WallType.Project); await _uow.SaveChangesAsync(userOrg.UserId); }
public IHttpActionResult SaveMap(SiteViewModel model) { foreach (var wall in model.WallViewModels) { if (wall.IsDirty) { if (!wall.IsDelete) { if (wall.Id != null) { if (!wall.Length.Equals(0)) { _wallService.UpdateWall( new WallUpdateModel { Angle = wall.Angle, Length = wall.Length, SiteId = wall.SiteId, WallId = wall.Id, X = wall.X, Y = wall.Y, Type = wall.Type, }, User.Identity.GetUserId()); } else { var deleteModel = new WallUpdateModel { SiteId = wall.SiteId, WallId = wall.Id }; _wallService.DeleteWall(deleteModel, User.Identity.GetUserId()); } } else if (wall.Length > 0) { _wallService.CreateWall(new WallUpdateModel { Angle = wall.Angle, Length = wall.Length, SiteId = wall.SiteId, WallId = wall.Id, X = wall.X, Y = wall.Y, Type = wall.Type, }); } } else { if (wall.Id != null) { var deleteModel = new WallUpdateModel { SiteId = wall.SiteId, WallId = wall.Id }; _wallService.DeleteWall(deleteModel, User.Identity.GetUserId()); } } } } var result = _siteService.GetSite(model.Id, User.Identity.GetUserId()); var obj = new { Success = true, Message = "", Result = result }; return(Ok(obj)); }