Beispiel #1
0
 public IActionResult ProjectLoad([FromBody] string ProjectID)
 {
     if (ProjectID != null)
     {
         var context   = new Model.Context();
         var projectdb = context.Projects.Where(c => c.Id == Convert.ToInt32(ProjectID)).FirstOrDefault();
         var Project   = new Tempproj();
         Project.Data = new ConectionData()
         {
             ConnectionString = projectdb.ConnectionString,
             ContextName      = projectdb.ContextName,
             ProjName         = projectdb.ProjectName
         };
         Project.Id           = projectdb.Id;
         Project.FileNames    = context.Model.Where(c => c.Projectid == projectdb.Id).Select(e => e.Filename).ToList();
         Project.Models       = context.Model.Where(c => c.Projectid == projectdb.Id).Select(e => e.Model1).ToList();
         Project.RandomEnding = randomEndingForFolder;
         context.Dispose();
         return(Ok(Project));
     }
     else
     {
         return(BadRequest());
     }
 }
Beispiel #2
0
        public void addProjToUser(ConectionData data, ScaffoldedModel models)
        {
            Model.Context context = new Model.Context();
            Model.User    user    = context.User.Where(c => c.LoginName == User.Identity.Name).FirstOrDefault();

            Model.Projects project = new Model.Projects();
            project.Owner            = user;
            project.OwnerId          = user.Id;
            project.ProjectName      = data.ProjName;
            project.ContextName      = data.ContextName;
            project.ConnectionString = data.ConnectionString;
            context.Add(project);
            foreach (var file in models.AdditionalFiles)
            {
                Model.Model model = new Model.Model();
                model.Project   = project;
                model.Projectid = project.Id;
                model.Model1    = file.Code;
                model.Filename  = Path.GetFileName(file.Path);
                context.Add(model);
            }
            Model.Model ContextModel = new Model.Model();
            ContextModel.Project   = project;
            ContextModel.Projectid = project.Id;
            ContextModel.Model1    = models.ContextFile.Code;
            ContextModel.Filename  = Path.GetFileName(models.ContextFile.Path);
            context.Add(ContextModel);
            context.SaveChanges();
            context.Dispose();
        }
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         context.Dispose();
     }
     base.Dispose(disposing);
 }
Beispiel #4
0
        public Tempproj GenerateTempProject(ConectionData data, string ending, ScaffoldedModel models)
        {
            DiplomWork.Model.Context context     = new Model.Context();
            Model.TempProjects       tempProject = new Model.TempProjects();
            tempProject.ConnectionString = data.ConnectionString;
            tempProject.ContextName      = data.ContextName;
            tempProject.ProjectName      = data.ProjName;
            Tempproj tempproj = new Tempproj();

            context.Add(tempProject);
            tempproj.Models    = new List <string>();
            tempproj.FileNames = new List <string>();
            foreach (var file in models.AdditionalFiles)
            {
                DiplomWork.Model.Model model = new DiplomWork.Model.Model();
                model.Tempproject           = tempProject.Id;
                model.Model1                = file.Code;
                model.Filename              = Path.GetFileName(file.Path);
                model.TempprojectNavigation = tempProject;
                context.Add(model);
                context.SaveChanges();
                tempproj.FileNames.Add(Path.GetFileName(file.Path));
                tempproj.Models.Add(file.Code);
            }
            tempproj.FileNames.Add(Path.GetFileName(models.ContextFile.Path));
            tempproj.Models.Add(models.ContextFile.Code);
            DiplomWork.Model.Model Contextmodel = new DiplomWork.Model.Model();
            Contextmodel.Tempproject = tempProject.Id;
            Contextmodel.Model1      = models.ContextFile.Code;
            Contextmodel.Filename    = Path.GetFileName(models.ContextFile.Path);
            context.Add(Contextmodel);

            context.SaveChanges();
            tempproj.Id           = tempProject.Id;
            tempproj.RandomEnding = ending;
            tempproj.Data         = data;
            context.Dispose();
            return(tempproj);
        }
        private ClaimsIdentity GetIdentity([FromBody] Person personfrmbody)
        {
            DiplomWork.Model.Context context = new Model.Context();
            people = context.User.ToList();
            context.Dispose();
            User person = people.FirstOrDefault(x => x.LoginName == personfrmbody.LoginName && x.Password == personfrmbody.Password);

            if (person != null)
            {
                var claims = new List <Claim>
                {
                    new Claim(ClaimsIdentity.DefaultNameClaimType, person.LoginName),
                    new Claim("DateTime", DateTime.Now.ToString("s", System.Globalization.CultureInfo.InvariantCulture))
                };
                ClaimsIdentity claimsIdentity =
                    new ClaimsIdentity(claims, "Token", ClaimsIdentity.DefaultNameClaimType,
                                       ClaimsIdentity.DefaultRoleClaimType);
                return(claimsIdentity);
            }

            // если пользователя не найдено
            return(null);
        }
Beispiel #6
0
        public IActionResult RemoveProject([FromBody] int projectID)
        {
            var context         = new Model.Context();
            var project         = context.Projects.Where(c => c.Id == projectID).FirstOrDefault();
            var models          = context.Model.Where(c => c.Projectid == projectID);
            var compiledContext = context.CompiledContext.Where(c => c.ProjectId == projectID).FirstOrDefault();

            if (compiledContext != null)
            {
                context.Remove(compiledContext);
            }
            if (models != null)
            {
                context.RemoveRange(models.AsEnumerable());
            }
            if (project != null)
            {
                context.Remove(project);
            }
            context.SaveChanges();
            context.Dispose();
            return(Ok());
        }