public async Task <IActionResult> Post(PostLogin model)
        {
            var TokenApi = new Token
            {
                TokenDef = _config.GetValue <string>("Token:TokenDef")
            };

            try
            {
                var login = await _repo.GetVendedorByUserAsync(model.Usuario);

                if (login == null)
                {
                    return(NotFound());
                }
                if (login.Senha == model.Senha)
                {
                    login.Token = TokenApi.TokenDef;
                    return(this.StatusCode(StatusCodes.Status200OK, login));
                }
                else
                {
                    return(this.StatusCode(StatusCodes.Status401Unauthorized, "Senha invalida"));
                }
            }
            catch (System.Exception ex)
            {
                return(this.StatusCode(StatusCodes.Status500InternalServerError, $"Banco de Dados Falhou.{ex.Message}"));
            }
        }
Пример #2
0
    public void OnClickLogin()
    {
        PostLogin postLogin = new PostLogin(inputUsuario.text, inputSenha.text);
        string    json      = JsonUtility.ToJson(postLogin);

        ServerConnection.Instance.Post(json, FinishRequest);
    }
Пример #3
0
        public async Task <IActionResult> Edit(int id, [Bind("EmployeeId,FirstName,LastName,MobileNo,JoiningDate,LeavingDate,IsWorking,Category,IsTailors,EMail,DateOfBirth,AdharNumber,PanNo,OtherIdDetails,Address,City,State,FatherName,HighestQualification,StoreId,UserId,EntryStatus,IsReadOnly")] Employee employee)
        {
            if (id != employee.EmployeeId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(employee);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EmployeeExists(employee.EmployeeId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            // ViewData["StoreId"] = new SelectList(_context.Stores, "StoreId", "StoreName", employee.StoreId);
            StoreInfo storeInfo = PostLogin.ReadStoreInfo(HttpContext.Session);

            ViewData["StoreId"]  = storeInfo.StoreId;
            ViewData["UserName"] = storeInfo.UserName;

            return(PartialView(employee));
        }
Пример #4
0
        public async Task <IActionResult> Create([Bind("AttendanceId,EmployeeId,AttDate,EntryTime,Status,Remarks,IsTailoring,StoreId,UserId,EntryStatus,IsReadOnly")] Attendance attendance)
        {
            if (ModelState.IsValid)
            {
                if (DBValidation.AttendanceDuplicateCheck(_context, attendance))
                {
                    ViewBag.ErrorMessage   = "Attendance already added!. Possible duplicate entry.";
                    ViewData["EmployeeId"] = new SelectList(_context.Employees, "EmployeeId", "StaffName", attendance.EmployeeId);
                    StoreInfo storeInfo1 = PostLogin.ReadStoreInfo(HttpContext.Session);
                    ViewData["StoreId"]  = storeInfo1.StoreId;
                    ViewData["UserName"] = storeInfo1.UserName;
                    return(View(attendance));
                }
                _context.Add(attendance);
                await _context.SaveChangesAsync();

                new PayrollManager().ONInsertOrUpdate(_context, attendance, false, false);
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["EmployeeId"] = new SelectList(_context.Employees, "EmployeeId", "StaffName", attendance.EmployeeId);
            StoreInfo storeInfo = PostLogin.ReadStoreInfo(HttpContext.Session);

            ViewData["StoreId"]  = storeInfo.StoreId;
            ViewData["UserName"] = storeInfo.UserName;
            return(View(attendance));
        }
Пример #5
0
        public PostLogin GetPostLogin(ISession session)
        {
            PostLogin ei = (Id != 0) ? (PostLogin)session.Load(typeof(PostLogin), Id) : new PostLogin();

            ei.Login = (Login)session.Load(typeof(Login), Login.Id);
            ei.Post  = (Post)session.Load(typeof(Post), Post.Id);
            return(ei);
        }
Пример #6
0
        private void button4_Click(object sender, EventArgs e)
        {
            string text = "";

            PostLogin f = JSON.Parse <PostLogin>(text);

            textBox3.Text = JSON.Stringify(f);
        }
Пример #7
0
        // GET: Payrolls/Employees/Create
        public IActionResult Create()
        {
            StoreInfo storeInfo = PostLogin.ReadStoreInfo(HttpContext.Session);

            ViewData["StoreId"]  = storeInfo.StoreId;
            ViewData["UserName"] = storeInfo.UserName;

            return(PartialView());
        }
Пример #8
0
        // GET: Payrolls/Attendances/Create
        public IActionResult Create()
        {
            ViewData["EmployeeId"] = new SelectList(_context.Employees, "EmployeeId", "StaffName");
            StoreInfo storeInfo = PostLogin.ReadStoreInfo(HttpContext.Session);

            ViewData["StoreId"]  = storeInfo.StoreId;
            ViewData["UserName"] = storeInfo.UserName;
            return(PartialView());
        }
 public void a_login_page_and_a_bad_password()
 {
     subject = new PostLogin {
               	Input = new Login {
               	        	Password = "******",
               	        	User = "******"
               	        }
               };
 }
 public void a_login_page_and_a_bad_password()
 {
     subject = new PostLogin();
     subject.Input = new Login
     {
         Password = "******",
         User = "******",
         ReturnUrl = target
     };
 }
Пример #11
0
 public JsonResult PostLogin([FromBody] PostLogin credentials)
 {
     //if credentials are valid then return the guid
     try{
         var user = mRepo.getUsers().First((n) => ((n.EmailAddress == credentials.EmailAddress) && n.PassWord == credentials.PassWord));
         return(Json(user));
     } catch (Exception ex) {
         Console.WriteLine("Error on PostLogin. MSG: " + ex.Message);
         //user not found, return a blank user
         return(Json(new User()));
     }
 }
Пример #12
0
        public PostLoginTest()
        {
            PostTest Post = new PostTest();

            AddDependentObject(Post);

            LoginTest login = new LoginTest();

            AddDependentObject(login);

            mPostLogin       = new PostLogin();
            mPostLogin.Post  = Post.Post;
            mPostLogin.Login = login.Login;
        }
        private dynamic Handle(PostLogin request)
        {
            var user = _repository.SingleOrDefault <User>(x => x.Username.ToLower() == request.Username.ToLower());

            if (user == null || user.Validate(request.Password) == false)
            {
                return(Response.AsJson(new LoginFailed(Context))
                       .WithContentType("application/vnd.siren+json; charset=utf-8"));
            }

            var accessToken = user.IssueAccessToken();

            _repository.SaveOrUpdate(user);

            return(new LoginSuccess(Context, accessToken));
        }
Пример #14
0
        public async Task <IActionResult> Create([Bind("EmployeeId,FirstName,LastName,MobileNo, JoiningDate,LeavingDate,IsWorking,Category,IsTailors,EMail,DateOfBirth,AdharNumber,PanNo,OtherIdDetails,Address,City,State,FatherName,HighestQualification,StoreId,UserId,EntryStatus,IsReadOnly")] Employee employee)
        {
            if (ModelState.IsValid)
            {
                _context.Add(employee);
                await _context.SaveChangesAsync();

                await EmployeeManager.PostEmployeeAdditionAsync(_context, employee, _userManager);

                return(RedirectToAction(nameof(Index)));
            }
            //ViewData["StoreId"] = new SelectList(_context.Stores, "StoreId", "StoreName", employee.StoreId);
            StoreInfo storeInfo = PostLogin.ReadStoreInfo(HttpContext.Session);

            ViewData["StoreId"]  = storeInfo.StoreId;
            ViewData["UserName"] = storeInfo.UserName;
            return(View(employee));
        }
Пример #15
0
 /// <summary>
 /// 获取登录令牌.
 /// </summary>
 /// <param name="text"></param>
 /// <returns></returns>
 private bool GetLoginToken(string text)
 {
     try
     {
         PostLogin pl = JSON.Parse <PostLogin>(text);
         if (pl.Result != null)
         {
             _LoginResult = pl;
             _VFWebQQ     = _LoginResult.Result.VFWebQQ;
             _PsessionID  = _LoginResult.Result.PsessionID;
             return(true);
         }
     }
     catch (Exception ex)
     {
         Loger.WriteLog(ex);
     }
     return(false);
 }
Пример #16
0
        // GET: StoreOperations
        public async Task <IActionResult> Index()
        {
            StoreInfo storeInfo    = PostLogin.ReadStoreInfo(HttpContext.Session);
            int       CurrentStore = storeInfo.StoreId;

            ViewData["UserName"] = storeInfo.UserName;

            var store = await _context.Stores.FindAsync(CurrentStore);

            if (store != null)
            {
                ViewBag.StoreName = store.StoreName;
                ViewBag.StoreCity = store.City;
            }
            else
            {
                ViewBag.StoreName = "N/A";
                ViewBag.StoreCity = "N/A";
            }
            ViewBag.StoreId = CurrentStore;

            // Check for Today Close and Openning Entry
            DateTime date = DateTime.Today.Date;
            //TODO: Update to IST Time zone
            //TODO: either of one should be shown
            var openToday = await _context.StoreOpens.Where(c => c.OpenningTime.Date == date.Date && c.StoreId == CurrentStore).FirstOrDefaultAsync();

            var closeToday = await _context.StoreCloses.Where(c => c.ClosingDate.Date == date.Date && c.StoreId == CurrentStore).FirstOrDefaultAsync();

            ViewBag.Open  = "true";
            ViewBag.Close = "true";
            if (openToday != null)
            {
                ViewBag.Open = "false";
            }
            if (closeToday != null)
            {
                ViewBag.Close = "false";
            }

            return(View());
        }
Пример #17
0
        // GET: Payrolls/Attendances/Edit/5
        public async Task <IActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var attendance = await _context.Attendances.FindAsync(id);

            if (attendance == null)
            {
                return(NotFound());
            }
            ViewData["EmployeeId"] = new SelectList(_context.Employees, "EmployeeId", "StaffName", attendance.EmployeeId);
            StoreInfo storeInfo = PostLogin.ReadStoreInfo(HttpContext.Session);

            ViewData["StoreId"]  = attendance.StoreId;
            ViewData["UserName"] = storeInfo.UserName;
            return(PartialView(attendance));
        }
Пример #18
0
        public async Task <IActionResult> OnPostAsync(string returnUrl = null)
        {
            returnUrl ??= Url.Content("~/");

            ExternalLogins = (await _signInManager.GetExternalAuthenticationSchemesAsync()).ToList();

            if (ModelState.IsValid)
            {
                // This doesn't count login failures towards account lockout
                // To enable password failures to trigger account lockout, set lockoutOnFailure: true
                var result = await _signInManager.PasswordSignInAsync(Input.Email, Input.Password, Input.RememberMe, lockoutOnFailure : false);

                if (result.Succeeded)
                {
                    _logger.LogInformation("User logged in.");
                    //Setting UserSession
                    PostLogin.SetUserSession(HttpContext.Session, db, Input.Email);
                    return(LocalRedirect(returnUrl));
                }
                if (result.RequiresTwoFactor)
                {
                    return(RedirectToPage("./LoginWith2fa", new { ReturnUrl = returnUrl, RememberMe = Input.RememberMe }));
                }
                if (result.IsLockedOut)
                {
                    _logger.LogWarning("User account locked out.");
                    return(RedirectToPage("./Lockout"));
                }
                else
                {
                    ModelState.AddModelError(string.Empty, "Invalid login attempt.");
                    return(Page());
                }
            }

            // If we got this far, something failed, redisplay form
            return(Page());
        }
Пример #19
0
        public async Task <IActionResult> Edit(int id, [Bind("AttendanceId,EmployeeId,AttDate,EntryTime,Status,Remarks,IsTailoring,StoreId,UserId,EntryStatus,IsReadOnly")] Attendance attendance)
        {
            if (id != attendance.AttendanceId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(attendance);
                    await _context.SaveChangesAsync();

                    new PayrollManager().ONInsertOrUpdate(_context, attendance, false, true);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AttendanceExists(attendance.AttendanceId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["EmployeeId"] = new SelectList(_context.Employees, "EmployeeId", "StaffName", attendance.EmployeeId);
            StoreInfo storeInfo = PostLogin.ReadStoreInfo(HttpContext.Session);

            ViewData["StoreId"]  = attendance.StoreId;
            ViewData["UserName"] = storeInfo.UserName;
            return(View(attendance));
        }