internal Keep GetById(int id) { var data = _repo.GetById(id); data.Views++; _repo.Edit(data); if (data == null) { throw new Exception("Invalid Id"); } return(data); }
internal Keep Edit(Keep editData, string userId) { Keep original = _repo.GetOne(editData.Id); if (original == null) { throw new Exception("Bad Id"); } if (editData.Name == null) { editData.Name = original.Name; } if (editData.Img == null) { editData.Img = original.Img; } if (editData.Description == null) { editData.Description = original.Description; } if (editData.Views == 0) { editData.Views = original.Views; } if (editData.Keeps == 0) { editData.Keeps = original.Keeps; } if (editData.Shares == 0) { editData.Shares = original.Shares; } if (original.CreatorId != userId) { if (editData.Name != original.Name || editData.Img != original.Img || editData.Description != editData.Description) { throw new Exception("Not the User : Access Denied"); } else { _repo.Edit(editData); return(_repo.GetOne(editData.Id)); } } _repo.Edit(editData); return(_repo.GetOne(editData.Id)); }
internal Keep Get(int id) { Keep original = _kRepo.Get(id); Keep edited = original; edited.Views++; edited = _kRepo.Edit(edited); if (original == null) { throw new Exception("Invalid Id"); } return(edited); }
// KeepToUpdate (ktu) can be updated by clicking the Keep button // Count keeps++ when added to Vault // Count keeps-- when removed from Vault // Count view++ on router KeepsDetails internal Keep Edit(Keep ktu, string userId) { Keep original = GetKeepById(ktu.Id, userId); if (ktu == null) { throw new Exception("Invalid Id"); } if (ktu.IsPrivate && ktu.UserId != userId) { throw new Exception("You cannot edit others' private posts!"); } if (ktu.UserId != userId) { throw new Exception("You cannot edit others' private posts!"); } // original.Name = ktu.Name == null ? original.Name : ktu.Name; // original.Description = ktu.Name == null ? original.Description : ktu.Description; // Author/userId is not to be changed. Ever. // original.Img = ktu.Img == null ? original.Img : ktu.Img; original.IsPrivate = ktu.IsPrivate == original.IsPrivate ? original.IsPrivate : ktu.IsPrivate; original.Views = ktu.Views != 0 ? ktu.Views : original.Views; // original.Shares = ktu.Shares != 0 ? ktu.Shares : original.Shares; original.Keeps = ktu.Keeps != 0 ? ktu.Keeps : original.Keeps; _repo.Edit(ktu); return(original); }
internal VaultKeep CreateVaultKeep(VaultKeep newVaultKeep) { newVaultKeep.Id = _vkRepo.Create(newVaultKeep); Keep vKeep = _kRepo.Get(newVaultKeep.KeepId); vKeep.Keeps++; _kRepo.Edit(vKeep); return(newVaultKeep); }
internal Keep Edit(Keep editKeep, string userId) { Keep original = Get(editKeep.id); if (original.creatorId != userId) { throw new Exception("Access Denied: Cannot Edit a Keep You did not Create"); } editKeep.name = editKeep.name == null ? original.name : editKeep.name; return(_repo.Edit(editKeep)); }
internal Keep Edit(Keep updated) { var original = GetById(updated.Id); if (original.CreatorId != updated.CreatorId) { throw new Exception("Invalid Edit Permissions"); } updated.Description = updated.Description != null ? updated.Description : original.Description; updated.Name = updated.Name != null ? updated.Name : original.Name; return(_repo.Edit(updated)); }
internal Keep Edit(Keep editData, string userId) { Keep original = Get(editData.Id); if (original.CreatorId != userId) { throw new Exception("Access Denied: Cannot edit a Keep you did not create, so cut it out"); } editData.Name = editData.Name == null ? original.Name : editData.Name; return(_repo.Edit(editData)); }
public Keep Edit(Keep updated, Profile userInfo) { Keep original = _repo.GetById(updated.Id); if (original == null) { throw new Exception("This keep does not exist!"); } original.Views++; _repo.Edit(original); return(original); }
internal Keep Edit(Keep keep, string userId) { Keep original = Get(keep.Id); if (userId != original.CreatorId) { throw new Exception("You are not the creator, you can't edit this."); } keep.Name = keep.Name == null ? original.Name : keep.Name; keep.Description = keep.Description == null ? original.Description : keep.Description; keep.Img = keep.Img == null ? original.Img : keep.Img; return(_kRepo.Edit(keep)); }
internal Keep Edit(Keep editKeep, string userId) { Keep original = _repo.GetOne(editKeep.Id); if (original == null) { throw new Exception("Incorrect Id"); } original.Views++; _repo.Edit(original); return(original); }
internal Keep Edit(Keep editKeep, string userId) { Keep preEdit = _repo.GetOne(editKeep.Id); if (preEdit == null) { throw new Exception("invalid id"); } if (preEdit.CreatorId != userId) { throw new NotAuthorized("cannot edit keep if you aren't the creator"); } return(_repo.Edit(editKeep)); }
internal Keep Edit(Keep editData, string userId) { Keep original = GetById(editData.Id); if (original.CreatorId != userId) { throw new Exception("You must be the Creator to Edit this"); } editData.Name = editData.Name == null ? original.Name : editData.Name; editData.Description = editData.Description == null ? original.Description : editData.Description; editData.Img = editData.Img == null ? original.Img : editData.Img; return(_krepo.Edit(editData)); }
internal Keep Edit(int id, Keep data, Profile userInfo) { Keep original = _keepsRepository.GetOne(id); if (original == null) { throw new Exception("Cannot find <Keep> with that <Id>"); } if (original.CreatorId != userInfo.Id) { throw new Exception("Invalid <Keep> creator"); } _keepsRepository.Edit(id, data); return(_keepsRepository.GetOne(id)); }
internal Keep Edit(Keep editedKeep, Profile userInfo) { Keep original = _repo.GetOne(editedKeep.Id); if (original == null) { throw new Exception("Does not exist"); } if (original.CreatorId != userInfo.Id) { throw new Exception("Access Denied"); } _repo.Edit(editedKeep); return(_repo.GetOne(editedKeep.Id)); }
internal Keep Edit(Keep keep, string userId) { Keep original = _repo.GetEdit(keep.Id); if (original == null) { throw new Exception("Invalid Keep"); } if (original.creatorId != userId) { throw new Exception("Unauthorized"); } _repo.Edit(keep); return(_repo.GetEdit(keep.Id)); }
internal Keep Edit(Keep editedKeep, string userId) { Keep originalKeep = _repo.GetOne(editedKeep.Id); if (originalKeep == null) { throw new Exception("Incorrect ID"); } if (originalKeep.CreatorId != userId) { throw new Exception("Not Your Keep"); } _repo.Edit(editedKeep); return(_repo.GetOne(editedKeep.Id)); }
internal Keep Edit(Keep updated) { var original = GetById(updated.Id); if (original.CreatorId != updated.CreatorId) { throw new Exception("Invalid Edit Permissions"); } updated.Name = updated.Name != null && updated.Name.Length > 2 ? updated.Name : original.Name; updated.Description = updated.Description != null ? updated.Description : original.Description; updated.Img = updated.Img != null ? updated.Img : original.Img; updated.Views = updated.Views; updated.Shares = updated.Shares; updated.Keeps = updated.Keeps; return(_repo.Edit(updated)); }
public Keep Edit(Keep editKeep) { Keep keep = _repo.Get(editKeep.Id); if (keep == null) { throw new Exception("Invalid Id"); } keep.Name = editKeep.Name; keep.Description = editKeep.Description; keep.Img = editKeep.Img; keep.IsPrivate = editKeep.IsPrivate; keep.Views = editKeep.Views; keep.Keeps = editKeep.Keeps; keep.Shares = editKeep.Shares; _repo.Edit(keep); return(keep); }