public object CreateNote(CreateNoteViewModel createNoteViewModel) { if (!ModelState.IsValid) { return(Request.CreateResponse(HttpStatusCode.BadRequest, new BaseResponse(ResponseStatus.ValidationError.ToString(), ModelState.Values.ToList()[0].Errors[0].ErrorMessage))); } CurrentUserInfo currentUserInfo = _tokenHelper.GetUserInfo(); NoteData NoteData = CreateNoteViewModel.GetNoteData(currentUserInfo.Id, createNoteViewModel); _NoteLogic.Add(NoteData); return(Request.CreateResponse(HttpStatusCode.OK, new BaseResponse(ResponseStatus.Success.ToString(), ResponseMessagesModel.Success))); }
public ActionResult AddPost(NoteCreateVM noteVm) { if (!ModelState.IsValid) { ViewBag.Notes = _noteLogic.GetAll(); return(View("Index", noteVm)); } var image = ReadImage(); var note = new Note { Text = noteVm.Text }; _noteLogic.Add(note, image); return(RedirectToAction("index")); }