Пример #1
0
        public ResponseDTO Add(ChepStokCikisDTO obj)
        {
            try
            {
                if (obj == null)
                {
                    return(BadRequest());
                }

                obj.ReferansNo = Convert.ToInt32(_definitionService.GetNextReferenceNumber("Cikis").Result);
                obj.InvoiceId  = Guid.NewGuid();

                var entity = Map(obj);
                entity.InvoiceAmount = entity.ChepStokCikisDetay.Sum(x => x.InvoiceAmount);

                var result = _uow.ChepStokCikis.Add(entity);
                foreach (var item in result.ChepStokCikisDetay)
                {
                    if (item.InvoiceDetailId == null)
                    {
                        item.InvoiceDetailId = Guid.NewGuid();
                    }
                }
                _uow.Commit();

                return(Success(result.StokCikisId));
            }
            catch (Exception ex)
            {
                return(Error(ex));
            }
        }
        public IActionResult GetNextReferenceNumber(string id)
        {
            var result = _service.GetNextReferenceNumber(id).Result;

            return(StatusCode(StatusCodes.Status200OK, result));
        }