public void Read_With_EmptyKeyword_Return_Success()
        {
            string           testName        = GetCurrentMethod();
            var              dbContext       = _dbContext(testName);
            IIdentityService identityService = new IdentityService {
                Username = "******"
            };
            DOSalesDetailLogic unitUnderTest = new DOSalesDetailLogic(GetServiceProvider(testName).Object, identityService, dbContext);

            var model = new DOSalesDetailModel()
            {
                ColorRequest     = "ColorRequest",
                ColorTemplate    = "ColorTemplate",
                ConstructionName = "ConstructionName"
            };

            dbContext.DOSalesLocalItems.Add(model);
            dbContext.SaveChanges();

            var result = unitUnderTest.Read(1, 1, "{}", new List <string>()
            {
                ""
            }, null, "{}");

            Assert.NotEmpty(result.Data);
        }
Ejemplo n.º 2
0
        public void Mapping_With_AutoMapper_Profiles()
        {
            var configuration = new MapperConfiguration(cfg =>
            {
                cfg.AddProfile <DOSalesMapper>();
                cfg.AddProfile <DOSalesDetailMapper>();
            });
            var mapper = configuration.CreateMapper();

            DOSalesViewModel salesInvoiceViewModel = new DOSalesViewModel {
                Id = 1
            };
            DOSalesModel salesInvoiceModel = mapper.Map <DOSalesModel>(salesInvoiceViewModel);

            Assert.Equal(salesInvoiceViewModel.Id, salesInvoiceModel.Id);

            DOSalesDetailViewModel salesInvoiceDetailViewModel = new DOSalesDetailViewModel {
                Id = 1
            };
            DOSalesDetailModel salesInvoiceDetailModel = mapper.Map <DOSalesDetailModel>(salesInvoiceDetailViewModel);

            Assert.Equal(salesInvoiceDetailViewModel.Id, salesInvoiceDetailModel.Id);
        }
        public override async void UpdateAsync(long id, DOSalesModel model)
        {
            try
            {
                if (model.DOSalesDetailItems != null)
                {
                    HashSet <long> detailIds = doSalesLocalLogic.GetIds(id);
                    foreach (var itemId in detailIds)
                    {
                        DOSalesDetailModel data = model.DOSalesDetailItems.FirstOrDefault(prop => prop.Id.Equals(itemId));
                        if (data == null)
                        {
                            await doSalesLocalLogic.DeleteAsync(itemId);
                        }
                        else
                        {
                            doSalesLocalLogic.UpdateAsync(itemId, data);
                        }
                    }

                    foreach (DOSalesDetailModel item in model.DOSalesDetailItems)
                    {
                        if (item.Id == 0)
                        {
                            doSalesLocalLogic.Create(item);
                        }
                    }
                }

                EntityExtension.FlagForUpdate(model, IdentityService.Username, "sales-service");
                DbSet.Update(model);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }