public Document CreateDocument(string Name, string AddedBy) { Document doc = new Document(); doc.Name = Name; doc.isArchived = false; doc.AddedBy = AddedBy; return doc; }
public Document SaveDocument(Document document) { ((DatabaseContext)this.Database).Documents.AddObject(document); ((DatabaseContext)this.Database).SaveChanges(); ((DatabaseContext)this.Database).Refresh(System.Data.Objects.RefreshMode.StoreWins, document); return document; }
/// <summary> /// Deprecated Method for adding a new object to the Documents EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToDocuments(Document document) { base.AddObject("Documents", document); }
public ActionResult Save(DocumentModel dm) { var postedFile = dm.Image; Document doc = new Document(); if (postedFile != null) { if (postedFile.ContentLength > 0) { int imageLength = postedFile.ContentLength; byte[] imageData = new byte[imageLength]; Stream imageStream = postedFile.InputStream; imageStream.Read(imageData, 0, imageLength); // update document if (dm.Id > 0) { doc = DocumentHelper.Instance.GetDocument(dm.Id); doc.Name = dm.Name; dm.Customer = CustomerHelper.Instance.GetCustomer(dm.Customer.Id); dm.Folder = FolderHelper.Instance.GetFolder(dm.Folder.Id); doc.Customer = dm.Customer; doc.Folder = dm.Folder; doc.Image = imageData; doc.ImageName = postedFile.FileName; doc.ImageMime = postedFile.ContentType; if (doc.Validate()) { doc = DocumentHelper.Instance.SaveDocument(doc); } } // save new document else { doc = DocumentHelper.Instance.CreateDocument(dm.Name, HttpContext.User.Identity.Name); doc.Name = dm.Name; dm.Customer = CustomerHelper.Instance.GetCustomer(dm.Customer.Id); dm.Folder = FolderHelper.Instance.GetFolder(dm.Folder.Id); doc.Customer = dm.Customer; doc.Folder = dm.Folder; doc.Image = imageData; doc.ImageName = postedFile.FileName; doc.ImageMime = postedFile.ContentType; doc.CreatedDate = DateTime.UtcNow; if (doc.Validate()) { doc = DocumentHelper.Instance.SaveDocument(doc); } } } } dm.Id = doc.Id; dm.Name = doc.Name; dm.Customers = CustomerHelper.Instance.GetAllCustomers(); dm.Folders = FolderHelper.Instance.GetAllFolders(); return View("ManageDocument",dm); }
/// <summary> /// Create a new Document object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="name">Initial value of the Name property.</param> /// <param name="isArchived">Initial value of the isArchived property.</param> /// <param name="image">Initial value of the Image property.</param> /// <param name="folderId">Initial value of the FolderId property.</param> /// <param name="customerId">Initial value of the CustomerId property.</param> /// <param name="addedBy">Initial value of the AddedBy property.</param> /// <param name="createdDate">Initial value of the CreatedDate property.</param> /// <param name="state">Initial value of the State property.</param> /// <param name="imageName">Initial value of the ImageName property.</param> /// <param name="imageMime">Initial value of the ImageMime property.</param> public static Document CreateDocument(global::System.Int32 id, global::System.String name, global::System.Boolean isArchived, global::System.Byte[] image, global::System.Int32 folderId, global::System.Int32 customerId, global::System.String addedBy, global::System.DateTime createdDate, global::System.Int32 state, global::System.String imageName, global::System.String imageMime) { Document document = new Document(); document.Id = id; document.Name = name; document.isArchived = isArchived; document.Image = image; document.FolderId = folderId; document.CustomerId = customerId; document.AddedBy = addedBy; document.CreatedDate = createdDate; document.State = state; document.ImageName = imageName; document.ImageMime = imageMime; return document; }