Ejemplo n.º 1
0
        public Business.Model.Document InsertOrUpdate(Business.Model.Document doc)
        {
            Document target = null;

            target = new Document
            {
                Id         = doc.Id,
                AuthorId   = doc.AuthorId,
                StateName  = doc.StateName,
                SchemeName = doc.SchemeName,
                State      = doc.StateName
            };
            _sampleContext.Documents.Add(target);

            target.Name      = doc.Name;
            target.ManagerId = doc.ManagerId;
            target.Comment   = doc.Comment;
            target.Sum       = doc.Sum;

            _sampleContext.SaveChanges();

            doc.Id     = target.Id;
            doc.Number = target.Number;

            return(doc);
        }
Ejemplo n.º 2
0
 private DocumentModel GetDocumentModel(Business.Model.Document d)
 {
     return(new DocumentModel()
     {
         Id = d.Id,
         AuthorId = d.AuthorId,
         AuthorName = d.Author.Name,
         Comment = d.Comment,
         ManagerId = d.ManagerId,
         ManagerName = d.ManagerId.HasValue ? d.Manager.Name : string.Empty,
         Name = d.Name,
         Number = d.Number,
         StateName = d.StateName,
         Sum = d.Sum
     });
 }
Ejemplo n.º 3
0
 public static TDoc ToDocumentModel <TDoc>(this Business.Model.Document d)
     where TDoc : DocumentModel, new()
 {
     return(new TDoc()
     {
         Id = d.Id,
         AuthorId = d.AuthorId,
         AuthorName = d.Author.Name,
         Comment = d.Comment,
         ManagerId = d.ManagerId,
         ManagerName = d.ManagerId.HasValue ? d.Manager.Name : String.Empty,
         Name = d.Name,
         Number = d.Number,
         StateName = d.StateName,
         Sum = d.Sum
     });
 }
Ejemplo n.º 4
0
        public Business.Model.Document InsertOrUpdate(Business.Model.Document doc)
        {
            Document target = null;

            if (doc.Id != Guid.Empty)
            {
                target = _sampleContext.Documents.Find(doc.Id);

                if (target == null)
                {
                    return(null);
                }
            }
            else
            {
                target = new Document
                {
                    Id        = Guid.NewGuid(),
                    AuthorId  = doc.AuthorId,
                    StateName = doc.StateName
                };
                _sampleContext.Documents.Add(target);
            }

            target.Name      = doc.Name;
            target.ManagerId = doc.ManagerId;
            target.Comment   = doc.Comment;
            target.Sum       = doc.Sum;

            _sampleContext.SaveChanges();

            doc.Id     = target.Id;
            doc.Number = target.Number;

            return(doc);
        }