コード例 #1
0
        public async Task <InvoiceCategoryDto> SaveAsync(Guid orgId, InvoiceCategoryDto dto)
        {
            if (orgId == null || orgId == Guid.Empty)
            {
                throw new ArgumentNullException("orgId", "Org id is missing");
            }

            InvoiceCategory category = _mapper.Map <InvoiceCategory>(dto);

            if (category.Id == Guid.Empty)
            {
                category.OrgId        = orgId;
                category.DateCreated  = DateTime.UtcNow;
                category.DateModified = null;
                await _context.InvoiceCategories.AddAsync(category);
            }
            else
            {
                category.OrgId        = orgId;
                category.DateModified = DateTime.UtcNow;
                _context.InvoiceCategories.Update(category);
            }
            await _context.SaveChangesAsync();

            dto = _mapper.Map <InvoiceCategoryDto>(category);
            return(dto);
        }
コード例 #2
0
        public InvoiceDataGrid(Invoice invoice)
        {
            this.BuildingId         = invoice.BuildingId;
            this.ContractorName     = invoice.ContractorName;
            this.CostAmount         = invoice.CostAmount;
            this.CreatedTime        = invoice.CreatedTime;
            this.InvoiceCategoryId  = invoice.InvoiceCategoryId;
            this.InvoiceDate        = invoice.InvoiceDate;
            this.InvoiceCreatedDate = invoice.InvoiceCreatedDate;
            this.InvoiceId          = invoice.InvoiceId;
            this.InvoiceNumber      = invoice.InvoiceNumber;
            this.IsDeleted          = invoice.IsDeleted;
            this.IsSettled          = invoice.IsSettled;
            this.Title                   = invoice.Title;
            this.CostAmountGross         = invoice.CostAmountGross;
            this.CostAmountConst         = invoice.CostAmountConst;
            this.CostAmountConstGross    = invoice.CostAmountConstGross;
            this.VariableVat             = invoice.VariableVat;
            this.CostAmountVariable      = invoice.CostAmountVariable;
            this.CostAmountVariableGross = invoice.CostAmountVariableGross;
            this.ConstVat                = invoice.ConstVat;

            using (var db = new DB.DomenaDBContext())
            {
                this.Building = db.Buildings.Where(x => x.BuildingId.Equals(invoice.BuildingId)).FirstOrDefault();
                this.Category = db.InvoiceCategories.Where(x => x.CategoryId.Equals(invoice.InvoiceCategoryId)).FirstOrDefault();
            }
        }
コード例 #3
0
        public async Task <bool> DeleteAsync(Guid id)
        {
            InvoiceCategory category = await _context.InvoiceCategories
                                       .FindAsync(id);

            if (category != null)
            {
                _context.InvoiceCategories.Remove(category);
                await _context.SaveChangesAsync();

                return(true);
            }
            throw new KeyNotFoundException("Invoice category not found");
        }
コード例 #4
0
        private void AddCategory(object param)
        {
            if (string.IsNullOrWhiteSpace(CategoryName))
            {
                LabelError = "Błędna nazwa";
                return;
            }
            var ic = new InvoiceCategory {
                CategoryName = CategoryName, CategoryId = Guid.NewGuid(), IsDeleted = false
            };

            CategoryCollection.Add(ic);

            commandBuffer.Add(new Helpers.CategoryCommand <InvoiceCategory> {
                CommandType = Helpers.CommandEnum.Add, Item = ic
            });
        }