public JsonResult DeleteReservation(string id) { try { if (string.IsNullOrWhiteSpace(id)) { throw new ArgumentException("id"); } var reservation = _reservationService.GetReservation(id); if (reservation == null) { throw new iPemException("预约不存在,删除失败。"); } if (reservation.Creator != (_workContext.Employee() != null ? _workContext.Employee().Name : _workContext.User().Uid)) { throw new ArgumentException("您没有操作权限。"); } _reservationService.Delete(reservation); _noteService.Add(new H_Note { SysType = 2, GroupID = "-1", Name = "M_Reservations", DtType = 0, OpType = 0, Time = DateTime.Now, Desc = "同步工程预约" }); _webLogger.Information(EnmEventType.Other, string.Format("删除预约[{0}]", reservation.Id), _workContext.User().Id, null); return(Json(new AjaxResultModel { success = true, code = 200, message = "删除成功" })); } catch (Exception exc) { _webLogger.Error(EnmEventType.Other, exc.Message, _workContext.User().Id, exc); return(Json(new AjaxResultModel { success = false, code = 400, message = exc.Message })); } }
public ApiResponse Post([FromBody] NoteModel model) { if (ModelState.IsValid) { int?movieId = _movieService.GetSingle(x => x.Id == model.MovieId)?.Id; if (movieId == 0 || movieId == null) { return new ApiResponse { IsSuccess = false, Message = "Film bulunamadı!" } } ; BLL.Note note = new Note { MovieId = model.MovieId, Notes = model.Note, Rate = model.Rate }; _noteService.Add(note); _noteService.SaveChanges(); return(new ApiResponse { IsSuccess = true, Message = "İşlem başarılı" }); } return(new ApiResponse { IsSuccess = false, Message = "Validasyon hatası" }); } }
public IActionResult PostMethod([FromBody] NewNoteRequestDto model) { if (ModelState.IsValid) { var dateTimeOffset = NotesService.GetDateTimeOffsetValue(model.Lifetime); var item = new NoteRepositoryItem { Id = NotesService.GenerateId(), Title = model.Title, Text = model.NoteText, CreateDateTime = DateTime.UtcNow, Lifetime = dateTimeOffset }; try { _notesService.Add(item); } catch (Exception exception) { // todo: log exception return(BadRequest("Can't add the note. Server error.")); } var result = item.ToDto(); return(Ok(result)); } return(BadRequest(ModelState)); }
public async Task <IActionResult> Create([FromBody] NoteBindingModel data) { var callerId = GetIdFromClaims(); if (data == null) { return(BadRequest("The payload must not be null.")); } if (string.IsNullOrWhiteSpace(data.Title)) { return(BadRequest("A title is required.")); } var note = new Note { Owner = callerId, Title = data.Title, Details = data.Details, Tags = data.Tags, Created = DateTime.Now, IsFavorited = false }; await _noteService.Add(note); return(Ok(_mapper.Map <NoteViewModel>(note))); }
public Mutation(INoteService noteService) { Field <NoteType>("addNote", arguments: new QueryArguments(new QueryArgument <NonNullGraphType <NoteInputType> > { Name = "note" }), resolve: ctx => noteService.Add(ctx.GetArgument <NoteInput>("note"))); }
public IActionResult Note(NoteViewModel viewModel) { if (ModelState.IsValid) { _noteService.Add(viewModel.Note); } return(RedirectToAction("NoteList")); }
public IActionResult Create([FromBody] NoteVm newNote) { if (newNote == null) { return(BadRequest()); } NoteVm result = _noteService.Add(newNote); return(Ok(result)); }
public async Task <ActionResult <NoteViewModel> > AddNote(NoteViewModel noteViewModel) { if (!ModelState.IsValid) { return(CustomResponse(ModelState)); } await _noteService.Add(_mapper.Map <Note>(noteViewModel)); return(CustomResponse(noteViewModel)); }
public IActionResult OpenNewNote(Note Note) { try { _NoteService.Add(Note); return(Ok("Successfull")); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public OperationStatusInfo <NoteDTO> AddNote(NoteDTO note) { _logger.Info($"User '{GetClientAddress()}' invoking {nameof(AddNote)} method."); try { var addedNote = _noteService.Add(note); return(GetSuccessOperationStatusInfo(addedNote)); } catch (Exception ex) { return(GetFailOperationStatusInfo <NoteDTO>(ex)); } }
static void notes() { note = new NoteManager(new EfNoteDal()); note.Add(new Note { Name = "test", Decsription = "makale yaz oğlum", CreateDate = DateTime.Now }); var lst = note.GetAll(); foreach (var item in lst) { Console.WriteLine(item.Name); } }
public ActionResult Create(NoteModel note) { note noteDomain = new note() { D_STATE = note.D_STATE, N_TOTAL = note.N_TOTAL, employee_U_ID = note.employee_U_ID, mission_M_ID = note.mission_M_ID, }; Service.Add(noteDomain); Service.Commit(); //Service.Dispose(); return(RedirectToAction("Index")); }
public ActionResult <NoteVM> Post([FromBody] NoteVM data) { if (!ModelState.IsValid) { return(new StatusCodeResult((int)HttpStatusCode.BadRequest)); } else { Note newNote = new Note(); newNote.UpdateNote(data); _noteService.Add(newNote); _noteService.Save(); return(Mapper.Map <NoteVM>(newNote)); } }
public IActionResult Post([FromBody] NoteModel model) { Note note = new Note { CategoryId = model.CategoryId.Value, NoteTitle = model.NoteTitle, NoteDescription = model.NoteDescription }; noteService.Add(note); ServiceResponse <Note> result = new ServiceResponse <Note> { Entity = note, IsSuccessFul = true }; return(Ok(result)); }
public IActionResult New(NoteViewModel vm) { if (ModelState.IsValid) { var noteDto = _mapper.Map <NoteDto>(vm); _noteService.Add(noteDto); if (noteDto.Id != default(int)) { SetClientSideNotificationMessage(_messageProvider.SuccessMessage(OperationType.Create, "note")); return(RedirectToAction("Edit", "Notes", new { id = noteDto.Id })); } } _noteViewModelFactory.PrepareTags(vm); return(View(vm)); }
public RedirectToActionResult InsertNote(AddNoteVM note) { if (ModelState.IsValid) { try { Note newNote = Mapper.Map <AddNoteVM, Note>(note); newNote.CreateBy = GetProfile(this.User).Id; newNote.CreationDate = DateTime.Now; _noteService.Add(newNote); } catch (Exception e) { Console.WriteLine(e); throw; } } return(RedirectToAction("Note")); }
public async Task <IActionResult> Create(NoteViewModel noteViewModel) { noteViewModel.Companies = await this.GetAllCompaniesList(); if (!ModelState.IsValid) { return(View(noteViewModel)); } var note = _mapper.Map <Note>(noteViewModel); note.CreatedAt = DateTime.Now; await _noteService.Add(note); if (!IsValidOperation()) { return(View(noteViewModel)); } return(RedirectToAction(nameof(Index))); }
public ActionResult <ItemResponse <int> > Add(AddNoteRequest model) { int iCode = 201; BaseResponse response = null; try { int userId = _authService.GetCurrentUserId(); int id = _service.Add(model, userId); response = new ItemResponse <int> { Item = id }; } catch (Exception ex) { iCode = 500; base.Logger.LogError(ex.ToString()); response = new ErrorResponse($"Server Error {ex.Message}"); } return(StatusCode(iCode, response)); }
public async Task <IActionResult> Add(Note note) { try { Note newNote = await _noteService.Add(note); var response = new Success <Note>() { Message = "Note created", Data = note, Code = 200 }; return(Ok(response)); } catch { return(StatusCode(500, new Error() { Message = "Something went wrong", Code = 500 })); } }
public async Task <IActionResult> Add([FromBody] NoteAddUpdateDto note) { if (note == null) { return(BadRequest("Note is null")); } var apiResponse = new ApiResponse(); try { var id = await _noteService.Add(note); apiResponse.Success = true; apiResponse.Message = "Added note successfully"; return(Created($"/notes/{id}", apiResponse)); } catch { apiResponse.Message = "Some error occurred while adding the note"; apiResponse.Success = false; return(StatusCode(500, apiResponse)); } }
public IActionResult Post([FromBody] NoteCreateUpdateDto note) { return(_noteService.Add(note)); }
public Note Add(NoteAddDto model) { return(_noteService.Add(model)); }
public async Task <ActionResult <NoteModel> > Add(NoteInput input) => await noteService.Add(input).MapToAction();
public void Add(NoteDto noteDto) { _noteService.Add(noteDto); }
public IActionResult Create([FromBody] NoteModel model) { _service.Add(model); return(Ok(model)); }
public async Task <IActionResult> Add(Note note) { var newNote = await _noteService.Add(note); return(await Get(newNote.Id)); }
public async Task <GenericResponse <Guid> > Post([FromBody] NoteCreateViewModel note) { return(await _noteService.Add(Mapper.Map <Note>(note))); }
public Note Add(NoteAddDto model) { Guid userId = _controllerUtilityService.GetAuthorizedUserId(User); return(_noteService.Add(userId, model)); }
public IActionResult Save(NoteDto noteDto) { var newNote = _noteService.Add(_mapper.Map <Note>(noteDto)); return(Created(string.Empty, _mapper.Map <NoteDto>(newNote))); }