Esempio n. 1
0
        public IHttpActionResult PostPaper(int paperId, PaperDO paper)
        {
            using (var transaction = this.unitOfWork.BeginTransaction())
            {
                GvaPaper paperData = this.unitOfWork.DbContext.Set<GvaPaper>()
               .Where(t => t.PaperId == paper.PaperId)
               .Single();

                paperData.ToDate = paper.ToDate.Value;
                paperData.FromDate = paper.FromDate.Value;
                paper.IsActive = paper.IsActive;

                this.unitOfWork.Save();

                transaction.Commit();

                return Ok();
            }
        }
Esempio n. 2
0
        public IHttpActionResult PostNewPaper(PaperDO paper)
        {
            using (var transaction = this.unitOfWork.BeginTransaction())
            {
                GvaPaper newPaper = new GvaPaper()
                {
                    Name = paper.Name,
                    IsActive = paper.IsActive,
                    FromDate = paper.FromDate.Value,
                    ToDate = paper.ToDate.Value,
                    FirstNumber = paper.FirstNumber.Value
                };

                this.unitOfWork.DbContext.Set<GvaPaper>().Add(newPaper);

                this.unitOfWork.Save();

                transaction.Commit();

                return Ok();
            }
        }