public object DeleteNote(DeleteNoteViewModel deleteNoteViewModel) { if (!ModelState.IsValid) { return(Request.CreateResponse(HttpStatusCode.BadRequest, new BaseResponse(ResponseStatus.ValidationError.ToString(), ModelState.Values.ToList()[0].Errors[0].ErrorMessage))); } CurrentUserInfo currentUserInfo = _tokenHelper.GetUserInfo(); if (!_NoteLogic.IsNoteExist(deleteNoteViewModel.ProjectId, deleteNoteViewModel.NoteId)) { return(Request.CreateResponse(HttpStatusCode.NotFound, new BaseResponse(ResponseStatus.Notfound.ToString(), ResponseMessagesModel.DailyActiviyNotFound))); } if (_projectLogic.GetUserRoleInProject(currentUserInfo.Id, deleteNoteViewModel.ProjectId) == UserRole.Collaborator && !_NoteLogic.IsNoteCreatedBy(currentUserInfo.Id, deleteNoteViewModel.NoteId)) { return(Request.CreateResponse(HttpStatusCode.MethodNotAllowed, new BaseResponse(ResponseStatus.ValidationError.ToString(), ResponseMessagesModel.PermissionDenied))); } _NoteLogic.Delete(deleteNoteViewModel.NoteId); return(Request.CreateResponse(HttpStatusCode.OK, new BaseResponse(ResponseStatus.Success.ToString(), ResponseMessagesModel.Success))); }
public IActionResult Delete([FromBody] Note note) { if (note.Id > 0) { return(Ok(_logic.Delete(note))); } return(BadRequest()); }