Exemple #1
0
 protected void JsonResult(Boolean isUpdate, Boolean isSuccess)
 {
     if (isSuccess)
     {
         sJsonResult = SUCCESS;
         ModelState.Clear();
         ViewData.Clear();
         if (isUpdate)
         {
             sJsonMsg = UPDATE_SUCCESS;
         }
         else
         {
             sJsonMsg = ADD_SUCCESS;
         }
     }
     else
     {
         sJsonResult = FAIL;
         if (isUpdate)
         {
             sJsonMsg = ADD_FAIL;
         }
         else
         {
             sJsonMsg = UPDATE_FAIL;
         }
     }
 }
        public ActionResult CreateLoan(ViewModelLoanGenerator viewModelLoan)
        {
            try
            {
                ViewData.Clear();
                var Monthpayment = new LoanBusinessLogic().GenerateLoan(new ViewModelLoan
                {
                    BirthDate = viewModelLoan.BirthDate,
                    Amount    = viewModelLoan.Amount,
                    Months    = viewModelLoan.Months,
                    UserLog   = viewModelLoan.Name
                });

                ViewBag.result       = "Record Inserted Successfully!";
                ViewBag.MonthPayment = Monthpayment;

                return(View("LoanDetail", new ViewModelLoanDetail()
                {
                    Amount = viewModelLoan.Amount,
                    MonthPayment = Monthpayment,
                    Months = viewModelLoan.Months,
                    Name = viewModelLoan.Name
                }));
            }
            catch (Exception e)
            {
                ViewBag.Error = e.Message;
                return(View("LoanCalculator", new ViewModelLoanGenerator()));
            }
        }
Exemple #3
0
        public bool UserValid()
        {
            if (HttpContext.Session != null && HttpContext.Session["loggedUser"] != null)
            {
                object ObjSession = Session["loggedUser"];

                user   UserCheck = (user)ObjSession;
                object UserDB    = UserService.GetUser(UserCheck.username, UserCheck.password);
                if (UserDB != null)
                {
                    LoggedUser                  = (user)UserDB;
                    ViewData["Name"]            = LoggedUser.name;
                    ViewData["IsAdmin"]         = LoggedUser.admin == 1;
                    ViewData["InstitutionName"] = LoggedUser.institution.name;
                    return(true);
                }
                else
                {
                    ViewData.Clear();
                    LoggedUser = null;
                    return(false);
                }
            }
            else
            {
                LoggedUser = null;
                return(false);
            }
        }
Exemple #4
0
        public IActionResult LoginUser(string Username, string Password)
        {
            //Is user in DB? User where or SingleOrDefault or firstordefault
            User user = _context.users.Where(Loginer => Loginer.Username == Username).SingleOrDefault();

            if (user != null && Password != null)
            {
                var Hasher = new PasswordHasher <User>();
                // Pass the user object, the hashed password, and the PasswordToCheck
                if (0 != Hasher.VerifyHashedPassword(user, user.Password, Password))
                {
                    HttpContext.Session.Clear();
                    ViewData.Clear();
                    HttpContext.Session.SetString("Name", user.FirstName);
                    var LoginID = _context.users.Where(Loginer => Loginer.UserID == user.UserID).First();
                    HttpContext.Session.SetInt32("UserID", LoginID.UserID);
                    TempData["UserID"] = HttpContext.Session.GetInt32("UserID");
                    TempData["Name"]   = HttpContext.Session.GetString("Name");
                    return(RedirectToAction("Success"));
                }
            }
            else
            {
                return(View("Index", ViewBag.Message));
            }
            ViewBag.Message = "There was an issue with logging in, please try again.";
            return(View("Index"));
        }
 // GET: Feature2
 public ActionResult Index()
 {
     try
     {
         ViewData.Clear();
         ClassName NewClass = new ClassName();
         if (!NewClass.GetTextFromPage())
         {
             return(View("~/Views/Shared/oops.cshtml"));
         }
         ViewData["Name1"] = @NewClass.ResponseString;
         if (!NewClass.GetTextFromPage())
         {
             return(View("~/Views/Shared/oops.cshtml"));
         }
         ViewData["Name2"] = @NewClass.ResponseString;
         if (!NewClass.GetTextFromPage())
         {
             return(View("~/Views/Shared/oops.cshtml"));
         }
         ViewData["Name3"] = @NewClass.ResponseString;
         return(View());
     }
     catch (Exception e)
     {
         Console.WriteLine("A class name could be retrieved. The error: '{0}'", e);
     }
     return(View("~/Views/Shared/oops.cshtml"));
 }
 public IActionResult Log_out()
 {
     ViewData.Clear();
     //ViewBag.Clear();
     HttpContext.Session.SetString("Pass", "5");
     return(RedirectToAction("Log_in", "Administrations"));
 }
 public ActionResult Authentication(AuthenticationModel authentication)
 {
     if (ModelState.IsValid)
     {
         if (authentication.InputCode == Session["OriginalCode"].ToString())
         {
             try
             {
                 var httpCient = Connector.GetHttpClient();
                 // for token
                 var user                = (UserRegistrationModel)Session["signUser"];
                 var response            = httpCient.PostAsJsonAsync <UserRegistrationModel>("Account/CreateEmployee", user).Result;
                 var httpResponseContent = response.Content.ReadAsStringAsync().Result;
                 if (response.IsSuccessStatusCode)
                 {
                     Session.Abandon();
                     Session.Clear();
                     ViewData.Clear();
                     return(RedirectToAction("UserLogin", "Account"));
                 }
             }
             catch (Exception ex)
             {
                 GlobalVariable.log.Error(ex.StackTrace, ex);
                 ModelState.AddModelError("", "Something went wrong, please try later");
                 return(View("Authentication"));
             }
         }
         ModelState.AddModelError("", "Wrong code");
         return(View("Authentication", authentication));
     }
     return(View("Authentication", authentication));
 }
Exemple #8
0
        private void GenerateSampleData()
        {
            ViewData.Clear();

            AddFolder("\\S2T82");
            //AddFolder("\\SamplePhotos\\Photo2");
            //AddFolder("\\SamplePhotos\\Photo3");
            //AddFolder("\\SamplePhotos\\Photo4");

            if (ViewData.Folders.Count > 1)
            {
                List <string> files = GetImagesInFolder(ViewData.Folders[0]);
                files.AddRange(GetImagesInFolder(ViewData.Folders[1]));

                //AddAlbum("Sample Album 1", DateTime.Now, "This is a sample album 1", files);
            }
            if (ViewData.Folders.Count > 3)
            {
                List <string> files = GetImagesInFolder(ViewData.Folders[2]);
                files.AddRange(GetImagesInFolder(ViewData.Folders[3]));

                //AddAlbum("Sample Album 2", DateTime.Now, "This is a sample album 2", files);
            }

            ViewData.Others.Name        = "Other";
            ViewData.Others.Date        = DateTime.Now;
            ViewData.Others.Description = "Other image files";

            UpdateData();
            // UpdateMainGalleryContent(true);
        }
 public ActionResult Authentication(AuthenticationModel Auth)
 {
     if (ModelState.IsValid)
     {
         if (Auth.InputCode == Session["OriginalCode"].ToString())
         {
             try
             {
                 var httpCient = Connector.GetHttpClient();
                 // for token
                 var client = (ClientSaveModel)Session["signUser"];
                 Session.Abandon();
                 Session.Clear();
                 var stringContent = Connector.GetStringOfObject(client);
                 var response      = httpCient.PostAsync("Account/ClientRegister", stringContent).Result;
                 if (response.IsSuccessStatusCode)
                 {
                     ViewData.Clear();
                     return(RedirectToAction("Login", "Account"));
                 }
             }
             catch (Exception ex)
             {
                 GlobalVariable.log.Error(ex.StackTrace, ex);
                 ModelState.AddModelError("", "Server error, please try later");
                 return(View("Authentication"));
             }
         }
         ModelState.AddModelError("", "Wrong code");
         return(View("Authentication", Auth));
     }
     return(View("Authentication", Auth));
 }
        public ActionResult Edit(FormCollection frm, string viewtoreturn)
        {
            if (Request.Form["deptID"] != null && Request.Form["nme"] != null && Request.Form["grnme"] != null && Request.Form["mddate"] != null)
            {
                string departmentID = Request.Form["deptID"].ToString();
                string name         = Request.Form["nme"].ToString();
                string groupename   = Request.Form["grnme"].ToString();
                string modifieddate = Request.Form["mddate"].ToString();
                System.Data.SqlClient.SqlConnection connection = new System.Data.SqlClient.SqlConnection("Data Source=(localdb)\\LocalInstance;Initial Catalog=AdventureWorks2012;Integrated Security=True");
                string cmdtext = "UPDATE [HumanResources].[Department] SET [Name] = '" + name + "',[GroupName] = '" + groupename + "',[ModifiedDate] = '" + modifieddate + "' WHERE [DepartmentID] = " + departmentID + "";
                System.Data.SqlClient.SqlCommand command = new System.Data.SqlClient.SqlCommand(cmdtext, connection);
                connection.Open();
                command.ExecuteNonQuery();
                connection.Close();
                ViewData.Clear();
            }


            if (viewtoreturn == "webindex")
            {
                return(View("WebIndex"));
            }
            else
            {
                return(View("Index"));
            }
        }
Exemple #11
0
 public ActionResult Dispatcher()
 {
     ViewData.Clear();
     ViewData.Add("assignedWithStatusByPerson", Dashboard.assignedWithStatusByPerson);
     ViewData.Add("emplNamesShort", Dashboard.emplNamesShort);
     ViewData.Add("pereodical", Dashboard.pereodicalBody);
     return(PartialView());
 }
Exemple #12
0
 public ActionResult Logout()
 {
     ViewData.Clear();
     Session.Clear();
     Session.Abandon();
     FormsAuthentication.SignOut();
     return(RedirectToAction("Index", "Login"));
 }
        public ActionResult Index(FormCollection frmc)
        {
            if (Request.Form["deptID"] != null && Request.Form["nme"] != null && Request.Form["grnme"] != null && Request.Form["mddate"] != null)
            {
                string departmentID = Request.Form["deptID"].ToString();
                string name         = Request.Form["nme"].ToString();
                string groupename   = Request.Form["grnme"].ToString();
                string modifieddate = Request.Form["mddate"].ToString();
                System.Data.SqlClient.SqlConnection connection = new System.Data.SqlClient.SqlConnection("Data Source=(localdb)\\LocalInstance;Initial Catalog=AdventureWorks2012;Integrated Security=True");
                string cmdtext = "UPDATE [HumanResources].[Department] SET [Name] = '" + name + "',[GroupName] = '" + groupename + "',[ModifiedDate] = '" + modifieddate + "' WHERE [DepartmentID] = " + departmentID + "";
                System.Data.SqlClient.SqlCommand command = new System.Data.SqlClient.SqlCommand(cmdtext, connection);
                connection.Open();
                command.ExecuteNonQuery();
                connection.Close();
                ViewData.Clear();
            }



            if (Request.Form["DepartmentID"] != null && Request.Form["Name"] != null && Request.Form["GroupName"] != null && Request.Form["ModifiedDate"] != null && Request.Form["EditingFormTrue"] != null)
            {
                // we pressed on edit

                ViewData["id"]           = Request.Form["DepartmentID"].ToString();
                ViewData["name"]         = Request.Form["Name"].ToString();
                ViewData["groupName"]    = Request.Form["GroupName"].ToString();
                ViewData["modifiedDate"] = Request.Form["ModifiedDate"].ToString();

                ViewData.Clear();
            }



            if (Request.Form["NAMETOADD"] != null && Request.Form["GROUPNAMETOADD"] != null && Request.Form["MODIFIEDDATETOADD"] != null)
            {
                string nametoadd         = Request.Form["NAMETOADD"].ToString();
                string groupenametoadd   = Request.Form["GROUPNAMETOADD"].ToString();
                string modifieddatetoadd = Request.Form["MODIFIEDDATETOADD"].ToString();
                System.Data.SqlClient.SqlConnection connectionnewadd = new System.Data.SqlClient.SqlConnection("Data Source=(localdb)\\LocalInstance;Initial Catalog=AdventureWorks2012;Integrated Security=True");
                string cmdtextaddnew = "INSERT INTO [HumanResources].[Department]([Name],[GroupName],[ModifiedDate])VALUES('" + nametoadd + "','" + groupenametoadd + "','" + modifieddatetoadd + "')";
                System.Data.SqlClient.SqlCommand command = new System.Data.SqlClient.SqlCommand(cmdtextaddnew, connectionnewadd);
                connectionnewadd.Open();
                command.ExecuteNonQuery();
                connectionnewadd.Close();
                ViewData.Clear();
            }


            if (Request.Form["viewtoretupd"] != null)
            {
                return(View("WebIndex"));
            }

            else
            {
                return(View("Index"));
            }
        }
        private void ExecuteClearAllCommand(object sender, ExecutedRoutedEventArgs e)
        {
            ExecuteStopCommand(sender, e);
            _jobRunner.Clear();
            ViewData.Clear();

            _jobRunner.BatchStatus = JobStatus.Ready;
            SaveList(DEFAULT_BATCH_JOB_LIST_FILENAME);
        }
        //Fetches role based on id
        private string FetchRoles(int id)
        {
            ViewData.Clear();

            //Obtaining list of roles
            var roleList = _roleService.FindAll().ToList();

            return(roleList.Where(r => r.RoleId == id).Select(r => r.RoleName).First());
        }
Exemple #16
0
 public ActionResult Index()
 {
     TempData.Clear();
     ViewData.Clear();
     Session.Clear();
     Session.Abandon();
     Response.Cookies.Clear();
     return(View("LogOutPage"));
 }
        public ActionResult Main()
        {
            ViewData.Clear();
            if (System.IO.File.Exists($"{_path.MapPath}"))
            {
                ViewBag.List = IO.Read();
            }

            return(View("Main"));
        }
        /// <summary>
        /// Fetches list of all roles and saves to ViewData["Roles"]
        /// </summary>
        private SelectList FetchRoles()
        {
            ViewData.Clear();

            //Obtaining list of roles
            var roleList = _roleService.FindAll().ToList();

            //Setting to select list for populating combo box
            return(new SelectList(roleList, "roleId", "roleName"));
        }
 // GET: FingerprintModels/Create
 public IActionResult RegisterUser()
 {
     if (HttpContext.Session.GetString("userName") != null)
     {
         TempData.Clear();
         ViewData.Clear();
         HttpContext.Session.Clear();
         return(RedirectToAction("Login", "Fingerprint"));
     }
     return(View());
 }
        public ActionResult ForgotPassword()
        {
            ViewData.Clear();
            TempData.Clear();
            Session.Clear();
            var auth = new logic.Rules.Authentication(Request.GetOwinContext());

            auth.Logout();

            return(View());
        }
        public JsonResult getStates(string name)
        {
            ViewData.Clear();
            var coun = _context.tblCountry.Where(x => x.CountryName == name).FirstOrDefault();

            var stateList = _context.tblState.Where(x => x.CountryId == coun.CountryId).ToList();

            ViewData["stateList"] = new SelectList(stateList, "StateId", "StateName");

            return(Json(stateList));
        }
        public ActionResult logout()
        {
            ViewData.Clear();
            TempData.Clear();
            Session.Clear();
            var auth = new logic.Rules.Authentication(Request.GetOwinContext());

            auth.Logout();

            return(RedirectToRoute("home"));
        }
 public IActionResult Signout()
 {
     if (ModelState.IsValid == true)
     {
         TempData.Clear();
         ViewData.Clear();
         HttpContext.Session.Clear();
         return(RedirectToAction("Login", "Fingerprint"));
     }
     return(View());
 }
        public ActionResult Register(string RegisterLogin, string RegisterPassword, string RegisterPhone, string RegisterName, string BirthDate, string Series, string ID)
        {
            db.Database.Connection.Open();
            List <long> codes = (from e in db.Пользователи where (e.Login == RegisterLogin && e.Password == RegisterPassword) select e.ПользовательID).ToList();

            if (codes.Count == 0)
            {
                ViewData.Clear();
                DBModels.Пользователи obj = new DBModels.Пользователи();
                long id = 0;
                try
                {
                    id = db.Пользователи.Max(e => e.ПользовательID) + 1;
                }
                catch
                {
                }
                obj.Login = RegisterLogin; obj.Password = RegisterPassword; obj.ПользовательID = id;
                db.Пользователи.Add(obj);
                db.SaveChanges();
                DBModels.Водители obj1 = new DBModels.Водители();
                obj1.ПользовательID = id; obj1.ПаспортныеДанные = Series + "|" + ID; obj1.ДеньРождения = BirthDate; obj1.ДатаРегистрации = DateTime.Today.Date.ToShortDateString();
                id = 0;
                try
                {
                    id = db.Водители.Max(e => e.ВодительID) + 1;
                }
                catch
                {
                }
                obj1.ВодительID = id;
                db.Водители.Add(obj1);
                db.SaveChanges(); db.Database.Connection.Close();
                return(RedirectToAction("LogIn"));
            }
            else
            {
                ViewData["Login"]        = RegisterLogin;
                ViewData["Password"]     = RegisterPassword;
                ViewData["Phone"]        = RegisterPhone;
                ViewData["Name"]         = RegisterName;
                ViewData["BirthDate"]    = BirthDate;
                ViewData["Series"]       = Series;
                ViewData["ID"]           = ID;
                TempData["alertMessage"] = "Аккаунт с указанными данными уже существует";
                db.Database.Connection.Close();
                ViewBag.logged = currentuser != null;
                ViewBag.type   = usertype;
                return(View());
            }
        }
        public ActionResult UserValidate(string useremail, string userpassword, FormCollection collection)
        {
            try {
                var user = db.users.FirstOrDefault(data => data.user_email == useremail && data.user_password == userpassword);
                if (user != null && user.user_email != null)
                {
                    if (collection["rememberme"] != null)
                    {
                        Response.Cookies.Clear();
                        Response.Cookies["userid"].Value         = useremail;
                        Response.Cookies["userpassword"].Value   = userpassword;
                        Response.Cookies["userid"].Expires       = DateTime.Now.AddDays(10);
                        Response.Cookies["userpassword"].Expires = DateTime.Now.AddDays(10);
                    }
                    else
                    {
                        Response.Cookies["userid"].Value       = "";
                        Response.Cookies["userpassword"].Value = "";
                    }
                    Session["user_role"] = user.user_role;

                    if (user.user_role == "seller")
                    {
                        var seller = db.sellers.FirstOrDefault(item => item.seller_email == user.user_email);
                        Session["seller_id"]   = seller.seller_id;
                        Session["seller_name"] = seller.seller_name;
                        Session["name"]        = seller.seller_name;
                        return(RedirectToAction("Index", "Prop"));
                    }
                    else
                    {
                        var customer = db.customers.FirstOrDefault(item => item.customer_email == user.user_email);
                        Session["customer_id"]  = customer.customer_id;
                        Session["cutomer_name"] = customer.customer_name;
                        Session["name"]         = customer.customer_name;
                        return(RedirectToAction("CustomerIndex", "Prop", new { s = customer.customer_state }));
                    }
                }
                else
                {
                    ViewData.Clear();
                    ViewData["error"] = "Invalid User Name or Password";
                    return(View("~/Views/Home/SignupLogin.cshtml"));
                }
            }
            catch (Exception)
            {
                // return Content(e.Message);
                return(RedirectToAction("Index", "Home"));
            }
        }
 public ActionResult EnterReason(long reqid)
 {
     if (currentuser != null)
     {
         ViewData.Clear();
         ViewData["Name"] = currentuser.Login;
         ViewBag.logged   = currentuser != null;
         ViewBag.type     = usertype;
         return(View());
     }
     else
     {
         return(RedirectToAction("LogIn"));
     }
 }
Exemple #27
0
 public ActionResult Login(OLogin PmtPeticion)
 {
     Usuario = (OUsuario)_D.Login(PmtPeticion).Respuesta[0];
     if (Usuario.Correcto)
     {
         ViewData.Clear();
         Session["Usuario"] = Usuario;
         return(View("~/Views/Usuario/Index.cshtml", Session["Usuario"]));
     }
     else
     {
         ViewBag.Mensaje = string.Format("bootbox.alert('<center><label>El correo electr&oacute;nico o la contraseña son incorrectos.</label></center>');");
         return(View("~/Views/Login/Index.cshtml"));
     }
 }
        //GET: workzone/Details/5
        //[AccessHelper(Menu = MenuHelper.VisualizacaoCadastro, Screen = ScreensHelper.PostodeTrabalho, Feature = FeaturesHelper.Editar)]
        public ActionResult Details(int id, string nome = "")
        {
            FuncListModel Func = new FuncListModel();

            Func.idWorkzone = id;
            var x = ViewBag.Name;

            ModelState.Clear();
            ViewData.Clear();
            UpdateModel(ViewData);
            /*  MONTANDO SELECT LIST BU, CC E LINHA*/
            setBUCCLINHA(id);
            /*FINALIZANDO SELECT LISTA BU, CC E LINHA*/

            SetImage();

            tblWorkzone workzone;

            workzone = _workzone.GetWorkzoneById(id);
            /*SELECIONA FUNCIONÁRIOS EXISTENTES*/
            IEnumerable <tblFuncionarios> employee;

            if (nome.Length > 0)
            {
                employee = _employee.GetEmployeeByName(nome, id);
            }
            else
            {
                employee = _employee.GetEmployees();
            }
            Func.funcionarios        = employee;
            ViewData["Funcionarios"] = employee;

            /* SELECIONA FUNCIONÁRIOS ADICIONADOS NESSA WZ*/
            IEnumerable <tblFuncionarios> employeeAdded;

            employeeAdded          = _workzone.setUpEmployees(id);
            Func.funcionariosAdded = employeeAdded;

            ViewData["FuncionariosAdicionados"] = employeeAdded;

            if (workzone == null)
            {
                return(View("Index"));
            }

            return(View("Edit", workzone));
        }
 public ActionResult ApplicationInfo(string Id)
 {
     if (currentuser != null)
     {
         ViewData.Clear();
         ViewData["Id"]   = Id;
         ViewData["Name"] = currentuser.Login;
         ViewBag.logged   = currentuser != null;
         ViewBag.type     = usertype;
         return(View());
     }
     else
     {
         return(RedirectToAction("LogIn"));
     }
 }
 public ActionResult DriverPanel()
 {
     if (currentuser != null)
     {
         ViewData.Clear();
         ViewData["User"] = currentuser.Login;
         ViewBag.logged   = currentuser != null;
         usertype         = "driver";
         ViewBag.type     = usertype;
         return(View());
     }
     else
     {
         return(RedirectToAction("LogIn"));
     }
 }