Пример #1
0
        public ActionResult GetCustomersListFilter(bool IsBlocked, string DateRange)
        {
            try
            {
                SuperAdminDAL       DAL       = new SuperAdminDAL();
                SuperAdminViewModel viewModel = new SuperAdminViewModel();
                string RequestStatus          = "Filtered";
                //DateTime? DateStart = null;
                //DateTime? DateEnd = null;
                string DateStart = null;
                string DateEnd   = null;
                if (DateRange != "")
                {
                    string[] DateFromTo = DateRange.Split('-');
                    DateStart = DateFromTo[0];
                    DateEnd   = DateFromTo[1];
                }

                viewModel.GetAllUsers = DAL.GetUsersList(RequestStatus, null, true, IsBlocked, DateStart, DateEnd);
                return(PartialView("_ManageGetCustomerList", viewModel));
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        public async Task <IActionResult> GiveRoleToUser(string userId, string roleId)
        {
            if (ModelState.IsValid)
            {
                var currentUser = await user.FindByIdAsync(userId);

                var rolesOfCurrentUser = await user.GetRolesAsync(currentUser);

                await user.RemoveFromRolesAsync(currentUser, rolesOfCurrentUser.ToArray());

                var currentRole = await roleManager.FindByIdAsync(roleId);

                var result = user.AddToRoleAsync(currentUser, currentRole.Name).Result;
                if (result.Succeeded)
                {
                }
            }
            var users = user.Users.ToList();
            var roles = roleManager.Roles.ToList();
            SuperAdminViewModel superAdminView = new SuperAdminViewModel()
            {
                Users = users,
                Roles = roles
            };

            return(View(superAdminView));
        }
Пример #3
0
        public ActionResult SuperAdmin()
        {
            var user_ = User.Identity;

            ViewBag.Name = user_.Name;
            context      = new ApplicationDbContext();
            //Super Admin Dashboard
            var Roles_ = context.Roles.ToList();

            var users_ = context.Users.ToList();

            var items = context.Items.ToList();

            var units = context.Units.ToList();

            var saleHeader = context.Sales_Headers.ToList();

            var saleDetails = context.Sales_Details.ToList();

            var vm = new SuperAdminViewModel()
            {
                user          = User.Identity.Name,
                users         = users_,
                roles         = Roles_,
                items         = items,
                units         = units,
                Sales_Header  = saleHeader,
                Sales_Details = saleDetails
            };

            return(View(vm));
        }
Пример #4
0
        public async Task <IActionResult> Post([FromBody] SuperAdminViewModel model)
        {
            try
            {
                var user = new User
                {
                    FullName    = model.FullName,
                    Email       = model.Email,
                    PhoneNumber = model.PhoneNumber
                };
                ILogger <UsersController> logger       = new LoggerFactory().CreateLogger <UsersController>();
                OkObjectResult            userResponse = (OkObjectResult)await new UsersController(Config, logger, DataContext).Post(user);
                var superAdmin = new SuperAdmin
                {
                    CoursesId  = model.CoursesId,
                    Deleted    = model.Deleted,
                    GroupsId   = model.GroupsId,
                    TeachersId = model.TeachersId,
                    UserId     = Convert.ToString(user.Id),
                };
                await UnitOfWork.Repository <SuperAdmin>().InsertAsync(superAdmin);

                return(new OkObjectResult(superAdmin.Id));
            }
            catch (Exception ex)
            {
                return(new BadRequestResult());
            }
        }
Пример #5
0
        public ActionResult GetCustomerAgainstCustomerIdForUpdate(int?UserProfileId)
        {
            SuperAdminViewModel viewmodel = new SuperAdminViewModel();
            SuperAdminDAL       DAL       = new SuperAdminDAL();

            viewmodel.GetUserProfileAndUserRegistration = DAL.GetCustomerAgainstCustomerIdForUpdate(UserProfileId);
            return(Json(viewmodel.GetUserProfileAndUserRegistration, JsonRequestBehavior.AllowGet));
        }
        public IActionResult GiveRoleToUser()
        {
            var users = user.Users.ToList();
            var roles = roleManager.Roles.ToList();
            SuperAdminViewModel superAdminView = new SuperAdminViewModel()
            {
                Users = users,
                Roles = roles
            };

            return(View(superAdminView));
        }
Пример #7
0
        public async Task <bool> Post(SuperAdminViewModel superAdmin)
        {
            try {
                var client  = new RestClient();
                var request = new RestRequest(url, Method.POST);
                request.RequestFormat = DataFormat.Json;
                request.AddHeader("Content-Type", "application/json");
                request.AddJsonBody(superAdmin);
                var restResponse = await client.ExecuteTaskAsync(request, CancellationToken.None);

                return(restResponse.IsSuccessful);
            } catch (Exception e) {
                return(false);
            }
        }
Пример #8
0
 public ActionResult GetCustomersList()
 {
     try
     {
         SuperAdminDAL       DAL       = new SuperAdminDAL();
         SuperAdminViewModel viewModel = new SuperAdminViewModel();
         string RequestStatus          = "All";
         viewModel.GetAllUsers = DAL.GetUsersList(RequestStatus, null, true, false, null, null);
         return(View(viewModel));
     }
     catch (Exception ex)
     {
         throw;
     }
 }
Пример #9
0
 public ActionResult InvitedUsers()
 {
     try
     {
         SuperAdminDAL       DAL       = new SuperAdminDAL();
         SuperAdminViewModel viewModel = new SuperAdminViewModel();
         int UserProfileId             = Convert.ToInt32(Session["UserProfileId"]);
         viewModel.PromotionEmailList = DAL.GetInvitedUsers(UserProfileId);
         return(View(viewModel));
     }
     catch (Exception ex)
     {
         throw;
     }
 }
Пример #10
0
 public ActionResult SaveCustomers(CustomerProfileAndRegistration CustomerProfileAndRegistration)
 {
     try
     {
         int                 status    = 0;
         SuperAdminDAL       DAL       = new SuperAdminDAL();
         SuperAdminViewModel viewModel = new SuperAdminViewModel();
         status = DAL.SaveCustomers(CustomerProfileAndRegistration);
         viewModel.GetUserProfileAndUserRegistrationRecord = DAL.GetUserProfileAndVendorRegistrationRecord(null, Convert.ToString(Session["UserType"]));
         return(PartialView("_ManageCustomer", viewModel));
     }
     catch (Exception ex)
     {
         throw;
     }
 }
Пример #11
0
        public async Task <IActionResult> SuperAdmin()
        {
            var users      = _applicationDbContext.Users.ToList();
            var superAdmin = new SuperAdminViewModel();

            superAdmin.Users = new List <SuperAdminViewModel.User>();
            foreach (var user in users)
            {
                var feeds = (await _feedService.GetFeedsAsync(user.UserName)).ToList();
                superAdmin.Users.Add(new SuperAdminViewModel.User
                {
                    UserName = user.UserName,
                    Feeds    = feeds
                });
            }
            return(View(superAdmin));
        }
Пример #12
0
 public ActionResult Customer()
 {
     try
     {
         int                 status    = 0;
         SuperAdminDAL       DAL       = new SuperAdminDAL();
         MVCUtility          utility   = new MVCUtility();
         SuperAdminViewModel viewModel = new SuperAdminViewModel();
         viewModel.DepartmentList = utility.GetLookupsByLookupType(true, "Department");
         viewModel.UserType       = utility.GetLookupsByLookupTypeTranslatedAsValueForUserType(true, "UserType", Convert.ToString(Session["UserType"]));
         viewModel.GetUserProfileAndUserRegistrationRecord = DAL.GetUserProfileAndVendorRegistrationRecord(null, Convert.ToString(Session["UserType"]));
         return(View(viewModel));
     }
     catch (Exception ex)
     {
         throw;
     }
 }
Пример #13
0
        public async Task <IActionResult> SuperAdmin(SuperAdminViewModel model)
        {
            if (ModelState.IsValid)
            {
                // Copy data from RegisterViewModel to IdentityUser
                var user = new ApplicationUser
                {
                    UserName  = model.Email,
                    Email     = model.Email,
                    FirstName = model.FirstName,
                    LastName  = model.LastName,
                    Address   = model.Address
                };

                // Store user data in AspNetUsers database table
                var result = await _userManager.CreateAsync(user, model.Password);

                // If user is successfully created, sign-in the user using
                // SignInManager and redirect to index action of HomeController
                if (result.Succeeded)
                {
                    await _signInManager.SignInAsync(user, isPersistent : false);

                    if (await _roleManager.FindByNameAsync(role2) == null)
                    {
                        await _roleManager.CreateAsync(new ApplicationRole(role2));
                    }
                    await _userManager.AddToRoleAsync(user, role2);

                    return(RedirectToAction("index", "home"));
                }

                // If there are any errors, add them to the ModelState object
                // which will be displayed by the validation summary tag helper
                foreach (var error in result.Errors)
                {
                    ModelState.AddModelError(string.Empty, error.Description);
                }
            }

            return(View(model));
        }
Пример #14
0
 public ActionResult DeleteUser(int UserProfileId, int UserRegistrationId)
 {
     try
     {
         SuperAdminViewModel            viewmodel = new SuperAdminViewModel();
         SuperAdminDAL                  DAL       = new SuperAdminDAL();
         CustomerProfileAndRegistration CustomerProfileAndRegistration = new CustomerProfileAndRegistration();
         CustomerProfileAndRegistration.UserRegistration    = new UserRegistration();
         CustomerProfileAndRegistration.UserProfile         = new UserProfile();
         CustomerProfileAndRegistration.UserRegistration.Id = Convert.ToInt32(UserRegistrationId);
         CustomerProfileAndRegistration.UserProfile.Id      = Convert.ToInt32(UserProfileId);
         int status = DAL.DeleteUser(CustomerProfileAndRegistration);
         viewmodel.GetUserProfileAndUserRegistrationRecord = DAL.GetUserProfileAndVendorRegistrationRecord(null, Convert.ToString(Session["UserType"]));
         return(PartialView("_ManageCustomer", viewmodel));
     }
     catch (Exception ex)
     {
         throw;
     }
 }
Пример #15
0
        public ActionResult SendEmailsToUsers(List <PromotionEmail> PromotionEmail)
        {
            try
            {
                if (PromotionEmail.Count > 0)
                {
                    for (int i = 0; i < PromotionEmail.Count; i++)
                    {
                        string              status            = "";
                        string              LimitationMessage = "";
                        SuperAdminDAL       DAL       = new SuperAdminDAL();
                        SuperAdminViewModel viewModel = new SuperAdminViewModel();
                        int    UserProfileId          = Convert.ToInt32(Session["UserProfileId"]);
                        string UserType  = Convert.ToString(Session["UserType"]);
                        string AuthToken = Guid.NewGuid().ToString();
                        if (UserType == "SuperAdmin")
                        {
                            AuthToken = AuthToken + "~10";
                            PromotionEmail[i].AllowedInvitations = 10;
                        }
                        else
                        {
                            AuthToken = AuthToken + "~0";
                            PromotionEmail[i].AllowedInvitations = 0;
                        }
                        PromotionEmail[i].AuthToken        = AuthToken;
                        PromotionEmail[i].InvitedBy        = UserProfileId;
                        PromotionEmail[i].RegistrationLink = "https://moments.fooddesignbrazil.com/Login/RegisterUser?Email=" + PromotionEmail[i].Email + "&AuthToken=" + AuthToken;

                        status = DAL.SaveInvitedUsers(UserProfileId, UserType, PromotionEmail[i]);

                        if (status == "AlreadyExists")
                        {
                            LimitationMessage = "This User Is Already Invited.";
                        }
                        else if (status == "Success")
                        {
                            //sending email
                            SendInvitationEmail(PromotionEmail[i].Email, PromotionEmail[i].RegistrationLink);
                            //sending email end
                            LimitationMessage = "Record Save Successfully.";
                        }
                        else if (status == "InvitationExceeded")
                        {
                            LimitationMessage = "Your Invitation Count Reached To Limit.";
                        }
                        else if (status == "NotPermission")
                        {
                            LimitationMessage = "Your have Not Permission To Invite.";
                        }
                        else
                        {
                            LimitationMessage = "";
                        }

                        // viewModel.PromotionEmailList = DAL.GetInvitedUsers(UserProfileId);

                        // var ManageInvitedUsers = RenderRazorViewToString(this.ControllerContext, "_ManageInvitedUsers", viewModel);

                        // string data = JsonConvert.SerializeObject(new { LimitationMessage, ManageInvitedUsers });
                    }
                }
                return(Json("Successfully Sent", JsonRequestBehavior.AllowGet));
                //  return PartialView("_ManageInvitedUsers", viewModel);
            }
            catch (Exception ex)
            {
                throw;
            }
        }