public Task <int> UpdateModel(int id, Models.AccountingCategory model)
        {
            var existingModel = _dbContext.AccountingCategories.FirstOrDefault(entity => entity.Id == id);

            existingModel.Code = model.Code;
            existingModel.Name = model.Name;
            MoonlayEntityExtension.FlagForUpdate(existingModel, _identityService.Username, UserAgent);
            _dbContext.AccountingCategories.Update(existingModel);
            return(_dbContext.SaveChangesAsync());
        }
Пример #2
0
        public async Task UploadData(InventoryWeavingDocument data, string username)
        {
            //IInventoryWeavingMovementService movement = ServiceProvider.GetService<IInventoryWeavingMovementService>();
            foreach (var i in data.Items)
            {
                MoonlayEntityExtension.FlagForCreate(i, username, USER_AGENT);
                MoonlayEntityExtension.FlagForUpdate(i, username, USER_AGENT);
            }
            MoonlayEntityExtension.FlagForCreate(data, username, USER_AGENT);
            MoonlayEntityExtension.FlagForUpdate(data, username, USER_AGENT);
            DbSet.Add(data);

            var result = await DbContext.SaveChangesAsync();

            foreach (var item in data.Items)
            {
                InventoryWeavingMovement movementModel = new InventoryWeavingMovement
                {
                    ProductOrderName = item.ProductOrderName,
                    BonNo            = data.BonNo,
                    ReferenceNo      = item.ReferenceNo,
                    Construction     = item.Construction,
                    Grade            = item.Grade,
                    //Piece = item.Piece,
                    MaterialName  = item.MaterialName,
                    WovenType     = item.WovenType,
                    Width         = item.Width,
                    Yarn1         = item.Yarn1,
                    Yarn2         = item.Yarn2,
                    YarnType1     = item.YarnType1,
                    YarnType2     = item.YarnType2,
                    YarnOrigin1   = item.YarnOrigin1,
                    YarnOrigin2   = item.YarnOrigin2,
                    UomId         = item.UomId,
                    UomUnit       = item.UomUnit,
                    Quantity      = item.Quantity,
                    QuantityPiece = item.QuantityPiece,
                    ProductRemark = item.ProductRemark,
                    Type          = data.Type,
                    InventoryWeavingDocumentId     = data.Id,
                    InventoryWeavingDocumentItemId = item.Id,
                    Barcode             = item.Barcode,
                    ProductionOrderDate = item.ProductionOrderDate,
                    DestinationArea     = item.DestinationArea


                                          //await BulkInsert(data, username);
                };
                MoonlayEntityExtension.FlagForCreate(movementModel, username, USER_AGENT);
                MoonlayEntityExtension.FlagForUpdate(movementModel, username, USER_AGENT);
                DbSet2.Add(movementModel);
            }
            var result2 = await DbContext.SaveChangesAsync();
        }
Пример #3
0
        public async Task <int> UpdateModel(int id, Models.AccountingUnit model)
        {
            var existingModel = _dbContext.AccountingUnits.FirstOrDefault(entity => entity.Id == id);

            existingModel.Code         = model.Code;
            existingModel.Description  = model.Description;
            existingModel.DivisionCode = model.DivisionCode;
            existingModel.DivisionId   = model.DivisionId;
            existingModel.DivisionName = model.DivisionName;
            MoonlayEntityExtension.FlagForUpdate(existingModel, _identityService.Username, UserAgent);
            _dbContext.AccountingUnits.Update(existingModel);
            var result = await _dbContext.SaveChangesAsync();

            SetCache();
            return(result);
        }
Пример #4
0
        public Task <int> UpdateModel(int id, Models.BICurrency model)
        {
            if (_dbContext.BICurrencies.Any(entity => entity.Code == model.Code && entity.Date.Date == model.Date.Date))
            {
                var errorResult = new List <ValidationResult>()
                {
                    new ValidationResult("Data with Code and same Date already exists", new List <string> {
                        "Duplicate"
                    })
                };
                ValidationContext validationContext = new ValidationContext(model, _serviceProvider, null);
                throw new ServiceValidationException(validationContext, errorResult);
            }

            var existingModel = _dbContext.BICurrencies.FirstOrDefault(entity => entity.Id == id);

            existingModel.Code = model.Code;
            existingModel.Date = model.Date;
            existingModel.Rate = model.Rate;
            MoonlayEntityExtension.FlagForUpdate(existingModel, _identityService.Username, UserAgent);
            _dbContext.BICurrencies.Update(model);
            return(_dbContext.SaveChangesAsync());
        }