internal Keep EditOneKeep(Keep editKeep) { Keep current = GetOneKeep(editKeep.Id); if (editKeep == null) { throw new SystemException("Invalid Id: This keep does not exist or the wrong Id was passed in the edit request."); } if (editKeep.CreatorId != current.CreatorId) { if (editKeep.Keeps > 0) { editKeep.Keeps = editKeep.Keeps > 0 ? editKeep.Keeps : current.Keeps; } if (editKeep.Views > 0) { editKeep.Views = editKeep.Views > 0 ? editKeep.Views : current.Views; } else { throw new SystemException("You are not the owner of this keep, you do not have permission to edit."); } } editKeep.Description = editKeep.Description != null ? editKeep.Description : current.Description; editKeep.Img = editKeep.Img != null ? editKeep.Img : current.Img; editKeep.Keeps = editKeep.Keeps > 0 ? editKeep.Keeps : current.Keeps; editKeep.Name = editKeep.Name != null ? editKeep.Name : current.Name; editKeep.Shares = editKeep.Shares > 0 ? editKeep.Shares : current.Shares; return(_krepo.EditOneKeep(editKeep)); }