Beispiel #1
0
        public void CreateTasks
        (
            string title,
            string details,
            DateTime?expirationDate,
            bool?isCompleted,
            int?effort,
            int?remainingWork,
            int?stateId,
            int?activityId,
            int?priorityId,
            int?projectId
        )
        {
            ProjectCore.DAL.Models.ProjectCoreContext _context = new ProjectCore.DAL.Models.ProjectCoreContext();

            _context.Tasks.Add(new ProjectCore.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 ProjectCore.DAL.Models.ProjectCoreContext();
                    _context.Tenants.Add(new ProjectCore.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());
        }
Beispiel #3
0
        /// <summary>
        /// GET PROJECTS BY ID OR TENANT OR USER PROJECT
        /// </summary>
        /// <param name="id"></param>
        /// <param name="tenantId"></param>
        /// <param name="userId"></param>
        /// <returns></returns>
        public List <Models.DB.Projects> GetPojects(int?id, int?tenantId, string userId = null)
        {
            DAL.Models.ProjectCoreContext _context = new DAL.Models.ProjectCoreContext();

            //var listProjectsEF = _context.Projects;

            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,
                ExpectedCompletationDate = _projects.ExpectedCompletionDate,
                TenantId = _projects.TenantId,
                CreateAt = _projects.CreatedAt,
                UpdateAt = _projects.UpdatedAt
            }).ToList();

            return(listProjects);
        }