Exemple #1
0
        public async Task <Project> CreateNewProject(ProjectServiceModel serviceModel)
        {
            var newProject = new Project
            {
                Name           = serviceModel.Name,
                BudgetMin      = serviceModel.BudgetMin,
                BudgetMax      = serviceModel.BudgetMax,
                CreateByUserId = serviceModel.User.Id,
                Details        = new List <ProjectDetail>()
                {
                    serviceModel.Detail
                },
                EntityFiles      = serviceModel.GetEntityFiles(),
                EntityTaxonomies = new List <ProjectTaxonomy>(
                    serviceModel.TaxonomyIds.Select(taxonomyId => new ProjectTaxonomy {
                    TaxonomyId = taxonomyId
                })),
                CityId        = serviceModel.CityId,
                ProjectBlocks = serviceModel.ProjectBlocks
            };

            var add = await _context.Project.AddAsync(newProject);

            _context.SaveChanges();

            return(add.Entity);
        }
Exemple #2
0
        public async Task <Package> CreateNewPackage(PackageServiceModel serviceModel)
        {
            var newPackage = new Package
            {
                Name           = serviceModel.Name,
                CreateByUserId = serviceModel.User.Id,
                PackageDetails = new List <PackageDetail>()
                {
                    serviceModel.Detail
                },
                EnitityFiles     = serviceModel.GetEntityFiles(),
                EntityTaxonomies = new List <PackageTaxonomy>(
                    serviceModel.TaxonomyIds.Select(taxonomyId => new PackageTaxonomy {
                    TaxonomyId = taxonomyId
                }))
            };

            var add = await _context.Package.AddAsync(newPackage);

            _context.SaveChanges();

            return(add.Entity);
        }