Beispiel #1
0
        public async Task <int> CreateAsync(DeliveryNoteProductionModel model)
        {
            int result = 0;

            using (var transaction = DbContext.Database.BeginTransaction())
            {
                try
                {
                    int index = 0;
                    do
                    {
                        model.Code         = CodeGenerator.Generate();
                        model.MonthandYear = model.Month + " " + model.Year;
                    }while (DbSet.Any(d => d.Code.Equals(model.Code)));

                    //DOSalesNumberGenerator(model, index);
                    deliveryNoteProductionLogic.Create(model);
                    index++;

                    result = await DbContext.SaveChangesAsync();

                    transaction.Commit();
                }
                catch (Exception e)
                {
                    transaction.Rollback();
                    throw new Exception(e.Message);
                }
            }

            return(result);
        }
Beispiel #2
0
        public async Task <int> UpdateAsync(int id, DeliveryNoteProductionModel model)
        {
            using (var transaction = DbContext.Database.BeginTransaction())
            {
                try
                {
                    model.MonthandYear = model.Month + " " + model.Year;
                    deliveryNoteProductionLogic.UpdateAsync(id, model);
                }
                catch (Exception e)
                {
                    transaction.Rollback();
                    throw new Exception(e.Message);
                }
            }

            return(await DbContext.SaveChangesAsync());
        }
Beispiel #3
0
        public async Task <int> DeleteAsync(int id)
        {
            using (var transaction = DbContext.Database.BeginTransaction())
            {
                try
                {
                    DeliveryNoteProductionModel model = await deliveryNoteProductionLogic.ReadByIdAsync(id);

                    if (model != null)
                    {
                        DeliveryNoteProductionModel doSalesModel = new DeliveryNoteProductionModel();
                        doSalesModel = model;
                        await deliveryNoteProductionLogic.DeleteAsync(id);
                    }
                }
                catch (Exception e)
                {
                    transaction.Rollback();
                    throw new Exception(e.Message);
                }
            }
            return(await DbContext.SaveChangesAsync());
        }