public void CreateTasks(string title, string details, DateTime?expirationDate, bool?isCompleted, int?effort, int?remaininWork, int?statedId, int?activityId, int?priorityId, int?projectId) { DAL.Models.ProyectoFinalClasesContext _context = new DAL.Models.ProyectoFinalClasesContext(); _context.Tasks.Add(new DAL.Models.Tasks { Title = title, ActivityId = activityId, Details = details, Effort = effort, ExpirationDate = expirationDate, IsCompleted = isCompleted, PriorityId = priorityId, ProjectId = projectId, RemainingWork = remaininWork, StateId = statedId }); _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 DAL.Models.ProyectoFinalClasesContext(); _context.Tenants.Add(new 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 void DeleteProjects(int id) { DAL.Models.ProyectoFinalClasesContext _context = new DAL.Models.ProyectoFinalClasesContext(); 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 UpdateProjects(int id, string title, string detail, DateTime?expectedCompletionDate) { DAL.Models.ProyectoFinalClasesContext _context = new DAL.Models.ProyectoFinalClasesContext(); var projectEF = _context.Projects.Where(x => x.Id == id).FirstOrDefault(); projectEF.Title = title; projectEF.Details = detail; projectEF.ExpectedCompletionDate = expectedCompletionDate; projectEF.UpdatedAt = DateTime.Now; _context.SaveChanges(); }
public void CreateProjects(string title, string details, DateTime?expectedCompletionDate, int?tenantId) { DAL.Models.ProyectoFinalClasesContext _context = new DAL.Models.ProyectoFinalClasesContext(); _context.Projects.Add(new DAL.Models.Projects { Title = title, Details = details, ExpectedCompletionDate = expectedCompletionDate, TenantId = tenantId, CreatedAt = DateTime.Now }); _context.SaveChanges(); }
public List <Models.DB.States> GetStates() { DAL.Models.ProyectoFinalClasesContext _context = new DAL.Models.ProyectoFinalClasesContext(); var listStates = (from _states in _context.States where _states.Active == true select new Models.DB.States { Id = _states.Id, Name = _states.Name, Active = _states.Active }).ToList(); return(listStates); }
public List <Models.DB.Tenants> GetTenants(string userId) { DAL.Models.ProyectoFinalClasesContext _context = new DAL.Models.ProyectoFinalClasesContext(); 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.Tasks> GetTasks(int?projectId, int?id) { DAL.Models.ProyectoFinalClasesContext _context = new DAL.Models.ProyectoFinalClasesContext(); 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, Details = _tasks.Details, Effort = _tasks.Effort, Title = _tasks.Title, ExpirationDate = _tasks.ExpirationDate, RemainingWork = _tasks.RemainingWork, IsCompleted = _tasks.IsCompleted, StateId = _tasks.StateId, State = new Models.DB.States { Name = _states.Name }, PriorityId = _tasks.PriorityId, Priority = new Models.DB.Priorities { Name = _priorities.Name }, ActivityId = _tasks.ActivityId, Activity = 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.Projects> GetProjects(int?id, int?tenantId, string userId = null) { DAL.Models.ProyectoFinalClasesContext _context = new DAL.Models.ProyectoFinalClasesContext(); 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); }