Esempio n. 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ProjectItemViewModel"/> class.
 /// </summary>
 /// <param name="Project">The Project item.</param>
 /// <param name="provider">The provider.</param>
 public ProjectItemViewModel(ProjectItem Project, ContentDataProviderBase provider)
     : base(Project, provider)
 {
     this.Address = Project.Address;
     this.City = Project.City;
     this.Region = Project.Region;
     this.PostalCode = Project.PostalCode;
 }
        /// <summary>
        /// Create a Project item with specific primary key
        /// </summary>
        /// <param name="id">Primary key</param>
        /// <returns>
        /// Newly created agent item in transaction
        /// </returns>
        public ProjectItem CreateProject(Guid id)
        {
            var Project = new ProjectItem();
            Project.Id = id;
            Project.ApplicationName = this.ApplicationName;
            Project.Owner = SecurityManager.GetCurrentUserId();
            var dateValue = DateTime.UtcNow;
            Project.DateCreated = dateValue;
            Project.PublicationDate = dateValue;
            ((IDataItem)Project).Provider = this;

            // items with empty guid are used in the UI to get a "blank" data item
            // -> i.e. to fill a data item with default values
            // if this is the case, we leave the item out of the transaction
            if (id != Guid.Empty)
            {
                this.GetContext().Add(Project);
            }
            return Project;
        }
        public void DeleteProject(ProjectItem Project)
        {
            var scope = this.GetContext();

            //this.ClearLifecycle(Project, this.GetProjects());
            if (scope != null)
            {
                scope.Remove(Project);
            }
        }