public void CreateTasks(string title, string details, DateTime?expirationDate, bool?isCompleted, int?effort, int?remainingWork, int?stateId, int?activityId, int?priorityId, int?projectId) { ProyectCore.DAL.Models.ProyectCoreContext _context = new ProyectCore.DAL.Models.ProyectCoreContext(); _context.Tasks.Add(new ProyectCore.DAL.Models.Tasks { Title = title, Details = details, ExpirationDate = expirationDate, IsCompleted = isCompleted, Effort = effort, RemainingWork = remainingWork, StateId = stateId, ActivityId = activityId, PriorityId = priorityId, ProjectId = projectId }); _context.SaveChanges(); }
public async Task <IActionResult> OnPostAsync(string returnUrl = null) { returnUrl = returnUrl ?? Url.Content("~/"); if (ModelState.IsValid) { var user = new IdentityUser { UserName = Input.Email, Email = Input.Email }; var result = await _userManager.CreateAsync(user, Input.Password); if (result.Succeeded) { _logger.LogInformation("User created a new account with password."); var code = await _userManager.GenerateEmailConfirmationTokenAsync(user); var callbackUrl = Url.Page( "/Account/ConfirmEmail", pageHandler: null, values: new { userId = user.Id, code = code }, protocol: Request.Scheme); await _emailSender.SendEmailAsync(Input.Email, "Confirm your email", $"Please confirm your account by <a href='{HtmlEncoder.Default.Encode(callbackUrl)}'>clicking here</a>."); #region Tenant var _context = new ProyectCore.DAL.Models.ProyectCoreContext(); _context.Tenants.Add(new ProyectCore.DAL.Models.Tenants { Name = Input.Organization, CreatedAt = DateTime.Now, Plan = Input.Plan }); _context.SaveChanges(); var aspNetUser = _context.AspNetUsers.Where(x => x.UserName.Equals(Input.Email)).FirstOrDefault(); aspNetUser.TenantId = _context.Tenants.Max(x => x.Id); _context.SaveChanges(); await _userManager.AddToRoleAsync(user, "Admin"); #endregion // await _signInManager.SignInAsync(user, isPersistent: false); return(LocalRedirect(returnUrl)); } foreach (var error in result.Errors) { ModelState.AddModelError(string.Empty, error.Description); } } // If we got this far, something failed, redisplay form return(Page()); }
public List <Models.DB.Tasks> GetTasks(int?projectId, int?Id) { ProyectCore.DAL.Models.ProyectCoreContext _context = new ProyectCore.DAL.Models.ProyectCoreContext(); var listTasks = (from _tasks in _context.Tasks join _states in _context.States on _tasks.StateId equals _states.Id join _activities in _context.Activities on _tasks.ActivityId equals _activities.Id join _priorities in _context.Priorities on _tasks.PriorityId equals _priorities.Id select new Models.DB.Tasks { Id = _tasks.Id, Title = _tasks.Title, Details = _tasks.Details, ExpirationDate = _tasks.ExpirationDate, IsCompleted = _tasks.IsCompleted, Effort = _tasks.Effort, RemainingWork = _tasks.RemainingWork, StateId = _tasks.StateId, States = new Models.DB.States { Name = _states.Name }, PriorityId = _tasks.PriorityId, Priorities = new Models.DB.Priorities { Name = _priorities.Name }, ActivityId = _tasks.ActivityId, Activities = new Models.DB.Activities { Name = _activities.Name }, ProjectId = _tasks.ProjectId }).ToList(); if (projectId != null) { listTasks = listTasks.Where(x => x.ProjectId == projectId).ToList(); } if (Id != null) { listTasks = listTasks.Where(x => x.Id == Id).ToList(); } return(listTasks); }
public List <Models.DB.Priorities> GetPriorities() { ProyectCore.DAL.Models.ProyectCoreContext _context = new ProyectCore.DAL.Models.ProyectCoreContext(); var listPriorities = (from _priorities in _context.Priorities where _priorities.Active == true select new Models.DB.Priorities { Id = _priorities.Id, Name = _priorities.Name, Active = _priorities.Active }).ToList(); return(listPriorities); }
public void UpdateProjects(int id, string title, string details, DateTime?expectedCompletionDate) { ProyectCore.DAL.Models.ProyectCoreContext _context = new ProyectCore.DAL.Models.ProyectCoreContext(); var projectEF = _context.Projects.Where(x => x.Id == id).FirstOrDefault(); projectEF.Title = title; projectEF.Details = details; projectEF.ExpectedCompletionDate = expectedCompletionDate; projectEF.UpdatedAt = DateTime.Now; _context.SaveChanges(); }
public void DeleteProjects(int?id) { ProyectCore.DAL.Models.ProyectCoreContext _context = new ProyectCore.DAL.Models.ProyectCoreContext(); if (_context.Artifacts.Any(x => x.ProjectId == id) || _context.UserProjects.Any(x => x.ProjectId == id)) { return; } var projectEF = _context.Projects.Where(x => x.Id == id).FirstOrDefault(); _context.Projects.Remove(projectEF); _context.SaveChanges(); }
public void CreateProjects(string title, string details, DateTime?expectedCompletionDate, int?tenantId) { ProyectCore.DAL.Models.ProyectCoreContext _context = new ProyectCore.DAL.Models.ProyectCoreContext(); _context.Projects.Add(new ProyectCore.DAL.Models.Projects { Title = title, Details = details, ExpectedCompletionDate = expectedCompletionDate, TenantId = tenantId, CreatedAt = DateTime.Now }); _context.SaveChanges(); }
public List <Models.DB.Tenants> GetTenants(string userId) { ProyectCore.DAL.Models.ProyectCoreContext _context = new ProyectCore.DAL.Models.ProyectCoreContext(); var listTenants = (from _tenants in _context.Tenants join _aspNetUsers in _context.AspNetUsers on _tenants.Id equals _aspNetUsers.TenantId where _aspNetUsers.Id.Equals(userId) select new Models.DB.Tenants { Id = _tenants.Id, Name = _tenants.Name, Plan = _tenants.Plan, CreatedAt = _tenants.CreatedAt, UpdatedAt = _tenants.UpdatedAt }).ToList(); return(listTenants); }
public List <Models.DB.Projects> GetProjects(int?id, int?tenantId, string userId = null) { ProyectCore.DAL.Models.ProyectCoreContext _context = new ProyectCore.DAL.Models.ProyectCoreContext(); var listProjectsEF = (from _projects in _context.Projects select _projects).ToList(); if (id != null) { listProjectsEF = listProjectsEF.Where(x => x.Id == id).ToList(); } if (tenantId != null) { listProjectsEF = listProjectsEF.Where(x => x.TenantId == tenantId).ToList(); } if (!string.IsNullOrEmpty(userId)) { listProjectsEF = (from _projects in listProjectsEF join _userProjects in _context.UserProjects on _projects.Id equals _userProjects.ProjectId where _userProjects.UserId.Equals(userId) select _projects).ToList(); } var listProjects = (from _projects in listProjectsEF select new Models.DB.Projects { Id = _projects.Id, Title = _projects.Title, Details = _projects.Details, ExpectedCompletionDate = _projects.ExpectedCompletionDate, TenantId = _projects.TenantId, CreatedAt = _projects.CreatedAt, UpdatedAt = _projects.UpdatedAt }).ToList(); return(listProjects); }