Ejemplo n.º 1
0
        public ActionResult SaveUnblockNumber(UnblockViewModel vm)
        {
            ControllerReturnStatus status = ControllerReturnStatus.Success;

            var ad = GetAdInfo();

            string fullName      = ad[0];
            string loginIdentity = ad[1];
            string department    = ad[2];

            try {
                var repo = new UnBlockNumberRepository();
                repo.AddExceptionPhoneNumber(vm.PhoneNumber, loginIdentity, fullName, department, vm.ReasonId, vm.StudentId, vm.NameAssigned, vm.Notes, vm.IsStudent);
            }
            catch {
                status = ControllerReturnStatus.Fail;
            }

            // Tell the modal what happened when we tried to save.
            string formattedPhone = Helpers.FormatPhoneNumber(vm.PhoneNumber);

            string message = "Phone number: " + formattedPhone;

            message += (status == 0 ? " was successfully Un-Blocked by user " + fullName : " was NOT Un-Blocked by user " + fullName);

            string title = (status == 0 ? "Success on Un-Blocking phone number " + formattedPhone : "Error on Un-Blocking phone number " + formattedPhone);

            var result = new { Status = status, Title = title, Message = message };

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 2
0
        public ActionResult ValidateLogin(LoginViewModel vm)
        {
            ControllerReturnStatus status = ControllerReturnStatus.Success;
            var model = new LoginViewModel();

            try {
                using (var context = new PrincipalContext(ContextType.Domain)) {
                    if (context.ValidateCredentials(vm.UserName, vm.Password))
                    {
                        var principal = UserPrincipal.FindByIdentity(context, User.Identity.Name);
                        if (principal != null)
                        {
                            model.FullName      = principal.DisplayName;                                        // RequestName
                            model.UserName      = principal.SamAccountName.ToUpper();                           // RequestId
                            model.ReqDepartment = "App Dev";                                                    // TODO: put all of this in a base class, and find department name.
                        }
                    }
                }
            } catch (Exception ex) {
                model.FullName = "Authentication failed";
            }

            string message = (status == ControllerReturnStatus.Fail ? "Login Failed for " + vm.UserName : "******" + model.FullName + "!");
            string title   = (status == ControllerReturnStatus.Fail ? "Login Failed" : "Login Successful.");

            var result = new { Status = status, Title = title, Message = message };

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 3
0
        public ActionResult SaveDncNumber(DncViewModel vm)
        {
            ControllerReturnStatus status = ControllerReturnStatus.Success;
            string additionalErrInfo      = string.Empty;

            var ad = GetAdInfo();

            string fullName      = ad [0];
            string loginIdentity = ad [1];
            string department    = ad [2];

            // for now, we are defalting to the global DNC = 1  Once the dropdown is back in place, we remove this.
            vm.DncNameId = 1;

            try {
                var repo = new DncRepository();
                repo.AddDncPhoneNumber(vm.PhoneNumber, loginIdentity, fullName, department, vm.DncNameId);
            } catch (Exception ex) {
                status = ControllerReturnStatus.Fail;
                if (ex.InnerException != null)
                {
                    if (ex.InnerException.ToString().Contains("duplicate"))
                    {
                        additionalErrInfo = " was NOT added to DNC because it already exists. - by user ";
                    }
                }
            }

            if (additionalErrInfo == string.Empty)
            {
                additionalErrInfo = " was NOT added to DNC by user ";
            }

            string formattedPhone = Helpers.FormatPhoneNumber(vm.PhoneNumber);

            // Tell the modal what happened when we tried to save.
            string message = "Phone number: " + formattedPhone;

            message += (status == 0 ? " was successfully added to DNC by user " + fullName : additionalErrInfo + fullName);

            string title = (status == 0 ? "Success on adding to DNC, phone number " + formattedPhone : "DNC phone number " + formattedPhone);

            var result = new { Status = status, Title = title, Message = message };

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
        public ActionResult SaveWhiteListNumber(WhiteListViewModel vm)
        {
            ControllerReturnStatus status = ControllerReturnStatus.Success;
            string additionalErrInfo      = string.Empty;

            var ad = GetAdInfo();

            string fullName      = ad [0];
            string loginIdentity = ad [1];
            string department    = ad [2];

            try {
                var repo = new WhiteListRepository();
                repo.AddWhiteListPhoneNumber(vm.PhoneNumber, loginIdentity, fullName, department, vm.Notes, vm.DncOverride);
            } catch (Exception ex) {
                status = ControllerReturnStatus.Fail;
                if (ex.InnerException != null)
                {
                    if (ex.InnerException.ToString().Contains("duplicate"))
                    {
                        additionalErrInfo = " was NOT added to white list because it already is in the white list - by user ";
                    }
                }
            }

            // Tell the modal what happened when we tried to save.
            string formattedPhone = Helpers.FormatPhoneNumber(vm.PhoneNumber);

            string message = "Phone number: " + formattedPhone;

            if (additionalErrInfo == string.Empty)
            {
                additionalErrInfo = " was NOT added to white list by user ";
            }
            message += (status == 0 ? " was successfully added to white list by user " + fullName + " DNC-Override set to:" + vm.DncOverride : additionalErrInfo + fullName + " DNC-Override set to:" + vm.DncOverride);

            string title = (status == 0 ? "Success on adding phone number " + formattedPhone : "Error on adding phone number " + formattedPhone);

            var result = new { Status = status, Title = title, Message = message };

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 5
0
        public ActionResult SaveCallCaps(AdminViewModel vm)
        {
            ControllerReturnStatus status = ControllerReturnStatus.Success;

            var ad = GetAdInfo();

            string fullName = ad [0];

            try {
                var repo = new AdminRepository();
                repo.UpdateCallCap(vm.ParmName1, vm.ParmValue1, fullName);
                repo.UpdateCallCap(vm.ParmName2, vm.ParmValue2, fullName);
                repo.UpdateCallCap(vm.ParmName3, vm.ParmValue3, fullName);
                repo.UpdateCallCap(vm.ParmName4, vm.ParmValue4, fullName);
                repo.UpdateCallCap(vm.ParmName5, vm.ParmValue5, fullName);
                repo.UpdateCallCap(vm.ParmName6, vm.ParmValue6, fullName);
                repo.UpdateCallCap(vm.ParmName7, vm.ParmValue7, fullName);
                repo.UpdateCallCap(vm.ParmName8, vm.ParmValue8, fullName);
                repo.UpdateCallCap(vm.ParmName9, vm.ParmValue9, fullName);
                repo.UpdateCallCap(vm.ParmName10, vm.ParmValue10, fullName);
                repo.UpdateCallCap(vm.ParmName11, vm.ParmValue11, fullName);
                repo.UpdateCallCap(vm.ParmName12, vm.ParmValue12, fullName);
            } catch {
                status = ControllerReturnStatus.Fail;
            }

            // Tell the modal what happened when we tried to save.
            string message = "Call Cap Update";

            message += (status == 0 ? " was successfully updated by user " + fullName : " was NOT updated by user " + fullName);

            string title = (status == 0 ? "Success on Call Cap Update" : "Error on Call Cap Update bu " + fullName);

            var result = new { Status = status, Title = title, Message = message };

            return(Json(result, JsonRequestBehavior.AllowGet));
        }