public async Task <int> CreateAsync(RO_Garment Model) { do { Model.Code = Code.Generate(); }while (this.DbSet.Any(d => d.Code.Equals(Model.Code))); CostCalculationGarment costCalculationGarment = await costCalGarmentLogic.ReadByIdAsync((int)Model.CostCalculationGarment.Id); //Model.CostCalculationGarment; foreach (var item in costCalculationGarment.CostCalculationGarment_Materials) { foreach (var itemModel in Model.CostCalculationGarment.CostCalculationGarment_Materials) { if (item.Id == itemModel.Id) { item.Information = itemModel.Information; } } } Model.CostCalculationGarment = null; roGarmentLogic.Create(Model); int created = await DbContext.SaveChangesAsync(); Model.ImagesPath = await AzureImageFacade.UploadMultipleImage(Model.GetType().Name, (int)Model.Id, Model.CreatedUtc, Model.ImagesFile, Model.ImagesPath); Model.DocumentsPath = await AzureDocumentFacade.UploadMultipleFile(Model.GetType().Name, (int)Model.Id, Model.CreatedUtc, Model.DocumentsFile, Model.DocumentsFileName, Model.DocumentsPath); await UpdateCostCalAsync(costCalculationGarment, (int)Model.Id); return(created); }
public async Task <int> CreateAsync(RO_Garment Model) { do { Model.Code = Code.Generate(); }while (this.DbSet.Any(d => d.Code.Equals(Model.Code))); CostCalculationGarment costCalculationGarment = await costCalGarmentLogic.ReadByIdAsync((int)Model.CostCalculationGarment.Id); //Model.CostCalculationGarment; Model.CostCalculationGarment = null; Model.ImagesPath = await this.AzureImageFacade.UploadMultipleImage(Model.GetType().Name, (int)Model.Id, Model.CreatedUtc, Model.ImagesFile, Model.ImagesPath); roGarmentLogic.Create(Model); await DbContext.SaveChangesAsync(); //Model.ImagesPath = await this.AzureImageService.UploadMultipleImage(Model.GetType().Name, Model.Id, Model._CreatedUtc, Model.ImagesFile, Model.ImagesPath); //await this.UpdateAsync((int)Model.Id, Model); //update CostCal return(await UpdateCostCalAsync(costCalculationGarment, (int)Model.Id)); }
public async Task <int> CreateAsync(GarmentSalesContract model) { //do //{ // model.Code = CodeGenerator.Generate(); //} //while (this.DbSet.Any(d => d.Code.Equals(model.Code))); CostCalculationGarment costCal = await costCalGarmentLogic.ReadByIdAsync(model.CostCalculationId); //await DbContext.CostCalculationGarments.FirstOrDefaultAsync(a => a.Id.Equals(model.CostCalculationId)); //costCal.SCGarmentId= garmentSalesContractLogic.Create(model); int result = await DbContext.SaveChangesAsync(); return(result += await UpdateCostCalAsync(costCal, (int)model.Id)); }