Exemplo n.º 1
0
		public void AddDocument(Document document)
		{
			document.Year = document.Date.Year;
			SetAutoNumber(document);
			var documentDao = Converter.Convert<Document, DocumentDao>(document);
			if (documentDao.AccountDt == null) documentDao.AccountDt = "";
			if (documentDao.AccountCt == null) documentDao.AccountCt = "";
			_dbContext.Documents.Add(documentDao);
			_dbContext.SaveChanges();
		}
Exemplo n.º 2
0
		public void UpdateDocument(Document document)
		{
			var dao = _dbContext.Documents.FirstOrDefault(c => c.Id.Equals(document.Id));
			dao.AccountCt = document.AccountCt;
			dao.AccountDt = document.AccountDt;
			dao.Number = document.Number;
			dao.Description = document.Description;
			dao.Date = document.Date;
			dao.Price = document.Price;
			_dbContext.SaveChanges();
		}
Exemplo n.º 3
0
		private void SetAutoNumber(Document document)
		{
			if (document.AutoNumber > 0) return;
			_allDocs = _dbContext.Documents.Where(c => c.Year.Equals(document.Date.Year) && c.ClientId.Equals(document.ClientId)).ToList();
			_autoNumber = 1;
			if (_allDocs.Any())
			{
				_autoNumber = _allDocs.Max(c => c.AutoNumber);
				_autoNumber++;
			}
			document.AutoNumber = _autoNumber;
		}
Exemplo n.º 4
0
		public ActionResult UpdateDocument(Document document)
		{
			_factory.GetDocumentsService().UpdateDocument(document);
			return new JsonResult { Data = true };
		}