public ActionResult Edit(int?id)
        {
            EmployeeLoginMappingModel model = new EmployeeLoginMappingModel();

            try
            {
                GetRolesList();

                if (!id.HasValue)
                {
                    DisplayWarningMessage("Looks like, the employee ID is missing in your request");
                    return(View(model));
                }

                if (!userService.Exists(id.Value))
                {
                    DisplayWarningMessage($"We are unable to retrieve the details for the give ID: {id}");
                    return(View(model));
                }

                EmployeeLoginMappingDto loginDto = userService.GetByID(id.Value);
                model = Mapper.Map <EmployeeLoginMappingDto, EmployeeLoginMappingModel>(loginDto);
            }
            catch (Exception exp)
            {
                DisplayLoadErrorMessage(exp);
            }
            return(View(model));
        }
        public void Add(EmployeeLoginMappingDto entity)
        {
            EmployeeLoginMapping user = CreateBusinessEntity(entity, true);

            Entities.Add(user);
            DataContext.Entry(user).State = EntityState.Added;
            DataContext.SaveChanges();

            postgresSqlProcessor.CreateMappingEntryForUserAndRole(user.LoginUserID, user.RoleID);
        }
        private void MigrateEntity(EmployeeLoginMappingDto sourceEntity, EmployeeLoginMapping targetEntity)
        {
            targetEntity.EmployeeID  = sourceEntity.EmployeeID;
            targetEntity.IsBlocked   = sourceEntity.IsBlocked;
            targetEntity.LoginUserID = sourceEntity.LoginUserID;
            targetEntity.MappingID   = sourceEntity.MappingID;
            targetEntity.RoleID      = sourceEntity.RoleID;

            targetEntity.UpdateTimeStamp(sourceEntity.LoggedInUserName);
        }
Пример #4
0
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            try
            {
                GetEmployeesList();
                GetRolesList();

                if (ModelState.IsValid)
                {
                    if (!(model.Email.ToLower().EndsWith("@agilisium.com") || model.Email.ToLower().EndsWith("@agileiss.com")))
                    {
                        DisplayWarningMessage("Please use Agilisium Email ID to register");
                        return(View(model));
                    }

                    ApplicationUser user = new ApplicationUser {
                        UserName = model.Email, Email = model.Email
                    };
                    IdentityResult result = await UserManager.CreateAsync(user, model.Password);

                    if (result.Succeeded)
                    {
                        EmployeeLoginMappingDto mapping = new EmployeeLoginMappingDto
                        {
                            EmployeeID     = model.EmployeeID,
                            LoginUserID    = user.Id,
                            RoleID         = model.RoleID,
                            LoginUserEmail = model.Email
                        };
                        userService.Add(mapping);
                    }
                    //return RedirectToAction("List", "ELogin");

                    await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);

                    //    // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771
                    //    // Send an email with this link
                    string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);

                    var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

                    AddErrors(result);

                    return(RedirectToAction("List", "ELogin"));
                    //}
                }
            }
            catch (Exception exp)
            {
                DisplayUpdateErrorMessage(exp);
            }
            // If we got this far, something failed, redisplay form
            return(View(model));
        }
        public void Delete(EmployeeLoginMappingDto entity)
        {
            EmployeeLoginMapping buzEntity = Entities.FirstOrDefault(e => e.MappingID == entity.MappingID);

            buzEntity.IsDeleted = true;
            buzEntity.UpdateTimeStamp(entity.LoggedInUserName);
            Entities.Add(buzEntity);
            DataContext.Entry(buzEntity).State = EntityState.Modified;
            DataContext.SaveChanges();

            postgresSqlProcessor.DeleteRoleMappingEntryForUser(entity.LoginUserID);
        }
        public void Update(EmployeeLoginMappingDto entity)
        {
            EmployeeLoginMapping user = Entities.FirstOrDefault(e => e.MappingID == entity.MappingID);

            user.IsBlocked = entity.IsBlocked;
            user.RoleID    = entity.RoleID;
            user.UpdateTimeStamp(entity.LoggedInUserName);
            Entities.Add(user);
            DataContext.Entry(user).State = EntityState.Modified;
            DataContext.SaveChanges();

            postgresSqlProcessor.UpdateMappingEntryForUserAndRole(user.LoginUserID, user.RoleID);
        }
        private EmployeeLoginMapping CreateBusinessEntity(EmployeeLoginMappingDto userDto, bool isNewEntity = false)
        {
            EmployeeLoginMapping user = new EmployeeLoginMapping
            {
                EmployeeID  = userDto.EmployeeID,
                IsBlocked   = userDto.IsBlocked,
                LoginUserID = userDto.LoginUserID,
                MappingID   = userDto.MappingID,
                RoleID      = userDto.RoleID,
            };

            user.UpdateTimeStamp(userDto.LoggedInUserName, true);

            return(user);
        }
 public ActionResult Edit(EmployeeLoginMappingModel model, int?page)
 {
     try
     {
         GetRolesList();
         EmployeeLoginMappingDto loginDto = Mapper.Map <EmployeeLoginMappingModel, EmployeeLoginMappingDto>(model);
         userService.Update(loginDto);
     }
     catch (Exception exp)
     {
         DisplayLoadErrorMessage(exp);
         return(View(model));
     }
     return(RedirectToAction("List", new { page }));
 }
 public void Update(EmployeeLoginMappingDto entity)
 {
     repo.Update(entity);
 }
 public void Delete(EmployeeLoginMappingDto entity)
 {
     repo.Delete(entity);
 }
 public void Add(EmployeeLoginMappingDto entity)
 {
     repo.Add(entity);
 }