public void Category_Equal_Category()
        {
            var first  = CategoryData.CategoryDomains.First();
            var second = new CategoryDomain(first.Name);

            Assert.True(first.Equals(second));
        }
        public Guid Add(string name, CategoryType type, int? num)
        {
            CategoryDomain domain = new CategoryDomain(name, type, num);
            unitOfWork.Commit();

            return domain.Entity.Id;
        }
        public void BatchAdd(DataTable table)
        {
            var types = _categoryRepository.GetAll(CategoryType.Outcome).ToDictionary(t => t.Name, v => v.Id);
            var users =  _personalAccountRepository.GetAll().ToDictionary(t => t.Name, v => v.Id);
            foreach (DataRow row in table.Rows)
            {
                var userName = Convert.ToString(row["付款人"]);
                if (string.IsNullOrWhiteSpace(userName))
                    break;

                var payDate = Convert.ToDateTime(row["支付日期"]);
                var amount = Convert.ToDecimal(row["支出"]);
                var typeName = Convert.ToString(row["类别"]);
                var categoryId = types[typeName];
                var payAcountId = users[userName];
                var remark = Convert.ToString(row["备注"]);

                var category = new CategoryDomain(categoryId);
                var payPersonal = new PersonalAccountDomain(payAcountId);

                var result = new PublicAccountWaterDomain(category, payPersonal, string.Empty, amount, payDate, remark);
            }

            unitOfWork.Commit();
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] CategoryDomain categoryDomain)
        {
            if (id != categoryDomain.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(categoryDomain);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CategoryDomainExists(categoryDomain.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(categoryDomain));
        }
        public void Category_Equal_Ok()
        {
            const string category = "обувь";

            var categoryDomain = new CategoryDomain(category);

            int categoryHash = HashCode.Combine(category);

            Assert.Equal(categoryHash, categoryDomain.GetHashCode());
        }
        public async Task <IActionResult> Create([Bind("Id,Name")] CategoryDomain categoryDomain)
        {
            if (ModelState.IsValid)
            {
                _context.Add(categoryDomain);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(categoryDomain));
        }
Exemple #7
0
        public async Task ValidateIncludes_CategoryNotFound()
        {
            var category            = new CategoryDomain("NotFound");
            var clothesType         = ClothesTypeData.ClothesTypeMainDomains.First();
            var clothesTypeNotFound = new ClothesTypeMainDomain(clothesType, category);

            var result = await ValidateIncludes(clothesTypeNotFound);

            Assert.True(result.HasErrors);
            Assert.True(result.Errors.First().ErrorResultType == ErrorResultType.ValueNotFound);
        }
        public Guid Add(Guid categoryId, Guid payAcountId, string payName, decimal amount,
             DateTime payDate, string remark)
        {
            var category = new CategoryDomain(categoryId);
            var payPersonal = new PersonalAccountDomain(payAcountId);

            var result = new PublicAccountWaterDomain(category, payPersonal, payName, amount, payDate, remark);
            unitOfWork.Commit();

            return result.Entity.Id;
        }
Exemple #9
0
        public void ClothesTypeMain_Equal_Ok()
        {
            const string   name                  = "Свитер";
            const SizeType sizeTypeDefault       = SizeType.American;
            var            categoryDomain        = new CategoryDomain("Верхушка");
            var            clothesTypeMainDomain = new ClothesTypeMainDomain(name, sizeTypeDefault, categoryDomain);

            int clothesTypeHash = HashCode.Combine(name, categoryDomain.GetHashCode());

            Assert.Equal(clothesTypeHash, clothesTypeMainDomain.GetHashCode());
        }
Exemple #10
0
        public void SetDropDownList()
        {
            using (var ctx = new ProductMNEntities())
            {
                var cateDomain = new CategoryDomain(ctx);
                var supDomain  = new SupplierDomain(ctx);

                var suppliers = supDomain.GetAll().Select(s => new DropDownListVMs
                {
                    Text  = s.CompanyName,
                    Value = s.SupplierID.ToString()
                }).ToList();

                var categories = cateDomain.GetAll().Select(c => new DropDownListVMs
                {
                    Text  = c.CategoryName,
                    Value = c.CategoryID.ToString()
                }).ToList();

                var discontinueds = new List <DropDownListVMs>
                {
                    new DropDownListVMs
                    {
                        Text  = "True",
                        Value = "true"
                    },
                    new DropDownListVMs
                    {
                        Text  = "False",
                        Value = "false"
                    },
                };

                Suppliers_ID.DataTextField  = "Text";
                Suppliers_ID.DataValueField = "Value";
                Suppliers_ID.DataSource     = suppliers;
                Suppliers_ID.DataBind();

                Categories_ID.DataTextField  = "Text";
                Categories_ID.DataValueField = "Value";
                Categories_ID.DataSource     = categories;
                Categories_ID.DataBind();

                Discountinued.DataTextField  = "Text";
                Discountinued.DataValueField = "Text";
                Discountinued.DataSource     = discontinueds;
                Discountinued.DataBind();
            }
        }
        public void AddTax(int multiple)
        {
            //TODO:改为配置
            var category = new CategoryDomain(Guid.Parse("6e1a7dd8-8589-42e3-bc06-ab22b1cf08a7"));
            _personalAccountRepository.GetAll(ApplicationContext.CurrentIdentity.AccountId)
               .ForEach(t =>
               {
                   var payPersonal = new PersonalAccountDomain(t.Id);
                   var salary = _salaryRepository.Last(t.Id);
                   var amount = salary.Amount * 0.05m * multiple;
                   new PublicAccountWaterDomain(category, payPersonal, payPersonal.Entity.Name, amount, DateTime.Now, string.Format("交共同费用。倍数{0},税率:{1},基数:{2}", multiple, "5%", salary.Amount));
               });

            unitOfWork.Commit();

        }
Exemple #12
0
            public static CategoryCollectionDomain GetUserCategories(string userId)
            {
                var credits    = new List <CategoryDomain>();
                var debits     = new List <CategoryDomain>();
                var collection = new CategoryCollectionDomain {
                    Credits = credits, Debits = debits
                };

                try
                {
                    DataProvider.ExecuteCmd(GetConnection, "dbo.select_category_byUserId",
                                            inputParamMapper : delegate(SqlParameterCollection paramCollection)
                    {
                        paramCollection.AddWithValue("@userId", userId);
                    },
                                            map : delegate(IDataReader reader, short set)
                    {
                        var category      = new CategoryDomain();
                        var predictions   = new PredictionCollectionDomain();
                        int startingIndex = 0;

                        category.CategoryId   = reader.GetSafeInt32(startingIndex++);
                        category.Name         = reader.GetSafeString(startingIndex++);
                        category.TypeId       = (TransactionType)reader.GetSafeInt32(startingIndex++);
                        category.ForecastType = reader.GetSafeString(startingIndex++);
                        predictions.Fixed     = reader.GetSafeInt32(startingIndex++);
                        predictions.Average   = reader.GetSafeInt32(startingIndex++);

                        category.Predictions = predictions;

                        if (category.TypeId == TransactionType.Credit)
                        {
                            collection.Credits.Add(category);
                        }
                        else
                        {
                            collection.Debits.Add(category);
                        }
                    });
                }
                catch (Exception e)
                {
                    throw e;
                }

                return(collection);
            }
        public EntityListResult<Category> FindAll()
        {
            CategoryDomain categoryDomain = new CategoryDomain(1, ATSCommon.Enums.LanguagesEnum.Arabic);
            EntityListResult<Category> entityListResult = new EntityListResult<Category>();
            try
            {
                entityListResult.ReturnedEntities = categoryDomain.FindAll();
                entityListResult.Message = string.Empty;
                if (categoryDomain.ActionState.Status != ATSCommon.Enums.ActionStatusEnum.NoError)
                {
                    entityListResult.Message = categoryDomain.ActionState.Result;
                }

            }
            catch (Exception ex)
            {
                entityListResult.Message = ex.Message;
            }
            return entityListResult;
        }
        public EntityResult<Category> FindByID(int entityID)
        {
            EntityResult<Category> entityResult = new EntityResult<Category>();
            CategoryDomain categoryDomain = new CategoryDomain(1, ATSCommon.Enums.LanguagesEnum.Arabic);

            try
            {
                entityResult.ReturnedEntity = categoryDomain.FindByID(entityID);
                if (categoryDomain.ActionState.Status != ATSCommon.Enums.ActionStatusEnum.NoError)
                {
                    entityResult.Message = categoryDomain.ActionState.Result;
                }

            }
            catch (Exception ex)
            {
                entityResult.Message = ex.Message;
            }
            return entityResult;
        }
 public static CategoryResponse ToResponse(this CategoryDomain domain) => new CategoryResponse
 {
     Id   = domain.Id,
     Name = domain.Name
 };
Exemple #16
0
 public void Update(CategoryDomain category)
 {
     _context.Categories.Update(category);
 }
Exemple #17
0
 public void Add(CategoryDomain category)
 {
     _context.Categories.Add(category);
 }