public async Task <Result <bool> > UpdateOrderNote([FromBody] ManageOrderNoteModel orderNoteModel) { if (!Validate(orderNoteModel)) { return(false); } var orderNote = await _orderNoteService.GetAsync(orderNoteModel.Id); if (orderNote == null) { throw new AppValidationException(ErrorMessagesLibrary.Data[ErrorMessagesLibrary.Keys.CantFindRecord]); } orderNote.Title = orderNoteModel.Title; orderNote.Description = orderNoteModel.Description; orderNote.CustomerTypes = orderNoteModel.CustomerTypes?.Select(x => new OrderNoteToCustomerType() { IdCustomerType = x }).ToList(); await _orderNoteService.UpdateOrderNoteAsync(orderNote, Convert.ToInt32(_userManager.GetUserId(User))); return(true); }
public async Task <Result <bool> > CreateOrderNote([FromBody] ManageOrderNoteModel orderNoteModel) { if (!Validate(orderNoteModel)) { return(false); } var orderNote = new OrderNote() { Title = orderNoteModel.Title, Description = orderNoteModel.Description, CustomerTypes = orderNoteModel.CustomerTypes?.Select(x => new OrderNoteToCustomerType() { IdCustomerType = x }).ToList(), }; await _orderNoteService.AddOrderNoteAsync(orderNote, Convert.ToInt32(_userManager.GetUserId(User))); return(true); }