Пример #1
0
        public Task <DataResult <DTOQuotationNote> > GetSpecifyNoteAsync(string quotationId, int statusId)
        {
            return(Task.Run(() =>
            {
                var noteDTO = new DTOQuotationNote();

                var note = quotationNoteRepository.GetFirstOrDefault(x => x.QuotationId == quotationId && x.StatusId == statusId,
                                                                     includes: new Expression <Func <QuotationNote, object> >[] { x => x.Quotation, x => x.Status });
                if (note != null)
                {
                    noteDTO = _mapper.Map <DTOQuotationNote>(note);
                }

                return new DataResult <DTOQuotationNote> {
                    Errors = new List <ErrorDescriber>(), Target = noteDTO
                };
            }));
        }
Пример #2
0
        public Task <DataResult <bool> > CreateOrUpdateNoteForSpecifyStepAsync(int noteId, DTOQuotationNote noteDTO)
        {
            return(Task.Run(() =>
            {
                if (noteId == noteDTO.Id)
                {
                    var noteEntity = quotationNoteRepository.GetById(noteId);

                    if (noteEntity == null)
                    {
                        noteEntity = _mapper.Map <QuotationNote>(noteDTO);
                        quotationNoteRepository.Insert(noteEntity);
                    }
                    else
                    {
                        noteEntity.Note = noteDTO.Note;
                        quotationNoteRepository.Update(noteEntity);
                    }

                    _unitOfWork.SaveChanges();
                }

                return new DataResult <bool> {
                    Errors = new List <ErrorDescriber>(), Target = true
                };
            }));
        }
Пример #3
0
 public async Task <IHttpActionResult> UpdateNoteForSpecifyStep(int noteId, [FromBody] DTOQuotationNote noteDTO)
 {
     return(await ExecuteServiceReturnDefaultResult(() => _serviceParameter.QuotationService.CreateOrUpdateNoteForSpecifyStepAsync(noteId, noteDTO), false));
 }