コード例 #1
0
        public async Task <IActionResult> PutCostCategory([FromRoute] Guid id, [FromBody] CostCategory costCategory)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != costCategory.CostCategoryId)
            {
                return(BadRequest());
            }

            _context.Entry(costCategory).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CostCategoryExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public static void ConfigureEntities(this ModelBuilder modelBuilder)
        {
            modelBuilder.Entity <Income>()
            .HasKey(b => b.Id);

            modelBuilder.Entity <Income>()
            .Property(i => i.Duration)
            .HasConversion(
                d => d.Value,
                d => Duration.FromValue(d));

            modelBuilder.Entity <FixedCost>()
            .HasKey(b => b.Id);

            modelBuilder.Entity <FixedCost>()
            .Property(i => i.Duration)
            .HasConversion(
                d => d.Value,
                d => Duration.FromValue(d));

            modelBuilder.Entity <FixedCost>()
            .Property(i => i.Category)
            .HasConversion(
                c => c.Value,
                c => CostCategory.FromValue(c));
        }
コード例 #3
0
ファイル: CostItemControl.cs プロジェクト: isysoi3/Doners
        private String getStringCategory(CostCategory category)
        {
            switch (category)
            {
            case CostCategory.ADVERTISMENT:
                return("Реклама");

            case CostCategory.COMMERCIAL:
                return("Ком.расходы");

            case CostCategory.EQUIPMENT:
                return("Оборудование");

            case CostCategory.HOUSEHOLD:
                return("Хоз.товары");

            case CostCategory.MEDICAL:
                return("Мед. товары");

            case CostCategory.PRESENTATIONAL:
                return("Пред.расходы");

            case CostCategory.PRODUCTS:
                return("Продукты");

            case CostCategory.SALARY:
                return("Зарплата");

            default:
                return("Другое");
            }
        }
コード例 #4
0
 public JoinedCost(Cost cost,
                   JoinedWallet wallet,
                   CostCategory costCategory)
 {
     Cost         = cost;
     Wallet       = wallet;
     CostCategory = costCategory;
 }
 public static BudgetPlanCategoryDto FromCategory(this CostCategory category)
 {
     return(category.Name switch
     {
         nameof(CostCategory.FlatAndOperating) => BudgetPlanCategoryDto.FlatAndOperating,
         nameof(CostCategory.MotorVehicle) => BudgetPlanCategoryDto.MotorVehicle,
         nameof(CostCategory.Insurance) => BudgetPlanCategoryDto.Insurance,
         nameof(CostCategory.Saving) => BudgetPlanCategoryDto.Saving,
         nameof(CostCategory.Other) => BudgetPlanCategoryDto.Other,
         _ => throw new ArgumentException($"Value {category} is not valid.", nameof(category))
     });
コード例 #6
0
 public CostItem(DataRow row)
 {
     date        = DateTime.Parse(row.Field <String>("date"));
     category    = (CostCategory)Enum.Parse(typeof(CostCategory), row.Field <String>("category"));
     name        = row.Field <String>("name");
     count       = row.Field <double>("count");
     costPerUnit = row.Field <double>("costPerUnit");
     discount    = row.Field <double>("discount");
     isCash      = bool.Parse(row.Field <String>("isCash"));
     comment     = row.Field <String>("comment");
 }
コード例 #7
0
ファイル: SyncService.cs プロジェクト: OLUWAMUYIWA/Finance
        public async Task <int> UploadOldCostAsync(CostCategory c, int OnlineId)
        {
            var thisCost = await _context.CostCategories.FindAsync(OnlineId);

            thisCost.Description = c.Description;
            thisCost.Name        = c.Name;
            thisCost.Type        = c.Type;
            await _context.SaveChangesAsync();

            return(thisCost.Id);
        }
コード例 #8
0
        public async Task <IActionResult> PostCostCategory([FromBody] CostCategory costCategory)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.CostCategory.Add(costCategory);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetCostCategory", new { id = costCategory.CostCategoryId }, costCategory));
        }
コード例 #9
0
        public async Task <CostCategory> AddCostCategory(CostCategory costCategory)
        {
            if (costCategory == null)
            {
                throw new ArgumentNullException(nameof(costCategory));
            }

            repository.Add(costCategory);
            await repository.SaveChangesAsync();

            return(costCategory);
        }
コード例 #10
0
 public AddFixedCostCommand(
     Guid userId,
     string name,
     double value,
     Duration duration,
     CostCategory category)
 {
     UserId   = userId;
     Name     = name;
     Value    = value;
     Duration = duration;
     Category = category;
 }
コード例 #11
0
        public async Task <int> SaveCostCategoryDetails(CostCategoryViewModel costCodeViewModel)
        {
            CostCategory costCategoryItem = new CostCategory
            {
                CostCategoryId       = costCodeViewModel.CostCategoryId,
                CostCategoryTitle    = costCodeViewModel.CostCategoryTitle,
                CostCategoryParentId = costCodeViewModel.CostCategoryParentId,
                CostCategoryDetails  = costCodeViewModel.CostCategoryDetails,
                isDeleted            = costCodeViewModel.isDeleted
            };
            var costCategoryObj = await _costCategoryRespository.CreateAsync(costCategoryItem);

            return(costCategoryObj.CostCategoryId);
        }
コード例 #12
0
 public CostItem(DateTime date,
                 CostCategory category,
                 String name,
                 double count,
                 double costPerUnit,
                 double discount,
                 bool isCash,
                 String comment)
 {
     this.date        = date;
     this.category    = category;
     this.name        = name;
     this.count       = count;
     this.costPerUnit = costPerUnit;
     this.discount    = discount;
     this.isCash      = isCash;
     this.comment     = comment;
 }
コード例 #13
0
        public async Task <IActionResult> Create([Bind("Id,CategoryName,MarkupPercent")] CostCategory costCategory)
        {
            if (ModelState.IsValid)
            {
                CostCategory ExistingCategory = _context.CostCategory
                                                .FirstOrDefault(cc => cc.CategoryName.ToUpper() == costCategory.CategoryName.ToUpper());

                if (ExistingCategory == null)
                {
                    _context.Add(costCategory);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction(nameof(Index)));
                }
                return(View("CreateDuplicate", costCategory));
            }
            return(View(costCategory));
        }
コード例 #14
0
ファイル: SyncService.cs プロジェクト: OLUWAMUYIWA/Finance
        public async Task <SavedList> UploadCostAsync(CostCategory c, int OldId)
        {
            try
            {
                //int ccId = c.Id;
                await _context.CostCategories.AddAsync(c);

                await _context.SaveChangesAsync();

                return(new SavedList {
                    Id = OldId,
                    Table = "CostCategories",
                    OnlineEntryId = c.Id
                });
            }
            catch (System.Exception e)
            {
                throw e;
            }
        }
コード例 #15
0
        public Estimate GetEstimateById(int?id)
        {
            using (SqlConnection conn = Connection) {
                conn.Open();
                using (SqlCommand cmd = conn.CreateCommand()) {
                    cmd.CommandText = @"SELECT e.id AS EstimateId, e.ProjectTitle, e.EstimateDate, 
                                               e.ExpirationDate, c.Id AS CustomerId, c.FirstName, c.LastName, 
                                               c.PhoneNumber, c.Email, ec.Id AS EstimateCostId, ci.Id AS CostItemId, 
                                               ci.ItemName, um.Id AS UnitId, um.UnitName, cc.Id AS CostCategoryId, 
                                               cc.CategoryName, cc.MarkupPercent, cpu.Cost, ec.Quantity, cec.Id AS CustomCostID, 
                                               cec.ItemName AS CustomItem, cec.CostPerUnit AS CustomCPU, cec.Quantity AS CustomQuantity, 
                                               cec.MarkupPercent, cec.UnitOfMeasure AS CustomUnits, cec.Category AS CustomCategory
                                          FROM Estimate e
                                     LEFT JOIN Customer c ON e.CustomerId = c.Id
                                     LEFT JOIN EstimateCost ec on ec.EstimateId = e.id
                                     LEFT JOIN CustomEstimateCost cec on cec.EstimateId = e.id
                                     LEFT JOIN CostItem ci ON ec.CostItemId = ci.Id
                                     LEFT JOIN CostPerUnit cpu ON cpu.CostItemId = ec.CostItemId AND cpu.EndDate IS NULL
                                     LEFT JOIN CostCategory cc ON ci.CostCategoryId = cc.Id
                                     LEFT JOIN UnitOfMeasure um ON ci.UnitOfMeasureId = um.Id 
                                         WHERE e.Id = @id
                                      ORDER BY e.EstimateDate DESC;";

                    cmd.Parameters.Add(new SqlParameter("@id", id));
                    SqlDataReader reader = cmd.ExecuteReader();

                    Estimate estimate = null;

                    while (reader.Read())
                    {
                        if (estimate == null)
                        {
                            estimate = new Estimate {
                                Id             = reader.GetInt32(reader.GetOrdinal("EstimateId")),
                                ProjectTitle   = reader.GetString(reader.GetOrdinal("ProjectTitle")),
                                EstimateDate   = reader.GetDateTime(reader.GetOrdinal("EstimateDate")),
                                ExpirationDate = reader.GetDateTime(reader.GetOrdinal("ExpirationDate")),
                                Customer       = new Customer {
                                    Id          = reader.GetInt32(reader.GetOrdinal("CustomerId")),
                                    FirstName   = reader.GetString(reader.GetOrdinal("FirstName")),
                                    LastName    = reader.GetString(reader.GetOrdinal("LastName")),
                                    Email       = reader.GetString(reader.GetOrdinal("Email")),
                                    PhoneNumber = reader.GetString(reader.GetOrdinal("PhoneNumber"))
                                },
                                EstimateCosts = new List <EstimateCost>(),
                                Categories    = new List <CostCategory>(),
                                CustomCosts   = new List <CustomEstimateCost>()
                            };
                        }

                        if (!reader.IsDBNull(reader.GetOrdinal("CustomCostId")))
                        {
                            int customCostId = reader.GetInt32(reader.GetOrdinal("CustomCostId"));

                            if (!estimate.CustomCosts.Any(cpc => cpc.Id == customCostId))
                            {
                                CustomEstimateCost customCost = new CustomEstimateCost {
                                    Id            = reader.GetInt32(reader.GetOrdinal("CustomCostId")),
                                    ItemName      = reader.GetString(reader.GetOrdinal("CustomItem")),
                                    CostPerUnit   = reader.GetDouble(reader.GetOrdinal("CustomCPU")),
                                    Quantity      = reader.GetInt32(reader.GetOrdinal("CustomQuantity")),
                                    UnitOfMeasure = reader.GetString(reader.GetOrdinal("CustomUnits")),
                                    Category      = reader.GetString(reader.GetOrdinal("CustomCategory")),
                                    MarkupPercent = reader.GetDouble(reader.GetOrdinal("MarkupPercent"))
                                };
                                estimate.CustomCosts.Add(customCost);
                            }
                        }

                        if (!reader.IsDBNull(reader.GetOrdinal("EstimateCostId")))
                        {
                            int estimateCostId = reader.GetInt32(reader.GetOrdinal("EstimateCostId"));

                            if (!estimate.EstimateCosts.Any(ec => ec.Id == estimateCostId))
                            {
                                EstimateCost estimateCost = new EstimateCost {
                                    Id       = reader.GetInt32(reader.GetOrdinal("EstimateCostId")),
                                    Quantity = reader.GetDouble(reader.GetOrdinal("Quantity")),
                                    CostItem = new CostItem {
                                        Id            = reader.GetInt32(reader.GetOrdinal("CostItemId")),
                                        ItemName      = reader.GetString(reader.GetOrdinal("ItemName")),
                                        UnitOfMeasure = new UnitOfMeasure {
                                            Id       = reader.GetInt32(reader.GetOrdinal("UnitId")),
                                            UnitName = reader.GetString(reader.GetOrdinal("UnitName"))
                                        },
                                        CostCategory = new CostCategory {
                                            Id            = reader.GetInt32(reader.GetOrdinal("CostCategoryId")),
                                            CategoryName  = reader.GetString(reader.GetOrdinal("CategoryName")),
                                            MarkupPercent = reader.GetDouble(reader.GetOrdinal("MarkupPercent"))
                                        },
                                    },

                                    CostPerUnit = reader.GetDouble(reader.GetOrdinal("Cost"))
                                };
                                estimate.EstimateCosts.Add(estimateCost);
                            }
                        }

                        if (!reader.IsDBNull(reader.GetOrdinal("CostCategoryId")))
                        {
                            int costCategoryId = reader.GetInt32(reader.GetOrdinal("CostCategoryId"));

                            if (!estimate.Categories.Any(c => c.Id == costCategoryId))
                            {
                                CostCategory category = new CostCategory {
                                    Id            = reader.GetInt32(reader.GetOrdinal("CostCategoryId")),
                                    CategoryName  = reader.GetString(reader.GetOrdinal("CategoryName")),
                                    MarkupPercent = reader.GetDouble(reader.GetOrdinal("MarkupPercent"))
                                };
                                estimate.Categories.Add(category);
                            }
                        }
                    }
                    reader.Close();
                    return(estimate);
                }
            }
        }
コード例 #16
0
 public void AddCostCategory(CostCategory CostCategory)
 {
     _db.Add(CostCategory);
     _db.SaveChanges();
 }
コード例 #17
0
 public void UpdateCostCategory(CostCategory CostCategory)
 {
     _db.Entry(CostCategory).State = EntityState.Modified;
     _db.SaveChanges();
 }