Ejemplo n.º 1
0
        public ActionResult ChangePassword(VM_AccountEmployee vM)
        {
            var putTask = client.PutAsJsonAsync <VM_AccountEmployee>("Accounts/" + vM.EmployeeId, vM);

            putTask.Wait();
            return(RedirectToAction("Login"));
        }
Ejemplo n.º 2
0
        public int Login(VM_AccountEmployee vM)
        {
            var spName = "SP_Login";

            parameters.Add("@Email", vM.Email);
            parameters.Add("@Password", vM.Passwords);
            var result = connection.Query <Int32>(spName, parameters, commandType: CommandType.StoredProcedure);

            return(result.FirstOrDefault());
        }
Ejemplo n.º 3
0
        public int Update(VM_AccountEmployee vM)
        {
            var spName = "SP_UpdateAccount";

            parameters.Add("@Email", vM.Email);
            parameters.Add("@Password", vM.Passwords);
            var result = connection.Execute(spName, parameters, commandType: CommandType.StoredProcedure);

            return(result);
        }
Ejemplo n.º 4
0
        public ActionResult Register(VM_AccountEmployee vM)
        {
            HttpResponseMessage response = client.PostAsJsonAsync("Accounts", vM).Result;

            if (response.IsSuccessStatusCode)
            {
                return(RedirectToAction("Login"));
            }
            return(View());
        }
Ejemplo n.º 5
0
        //public IHttpActionResult Get()
        //{
        //    var getAll = accountRepository.Get();
        //    if (getAll != null)
        //    {
        //        return Ok(getAll);
        //    }
        //    return NotFound();
        //}

        public IHttpActionResult Put(VM_AccountEmployee vM)
        {
            var UpdateAccount = accountRepository.Update(vM);

            if (UpdateAccount == 0)
            {
                return(BadRequest());
            }
            return(Ok());
        }
Ejemplo n.º 6
0
        public IHttpActionResult Post(VM_AccountEmployee vM_AccountEmployee)
        {
            var CreateAccount = accountRepository.Create(vM_AccountEmployee);

            if (CreateAccount == 0)
            {
                return(BadRequest());
            }
            return(Ok("data has been inputted"));
        }
Ejemplo n.º 7
0
        // GET: Login
        public IHttpActionResult Post(VM_AccountEmployee vM)
        {
            var Login = accountRepository.Login(vM);

            //Login.Wait();

            //var temp = Login.Result.ToList();
            if (Login == 0)
            {
                return(NotFound());
            }
            return(Ok(Login));
        }
Ejemplo n.º 8
0
        public int Create(VM_AccountEmployee vM_AccountEmployee)
        {
            var spName = "SP_InsertEmployeeAccount";

            parameters.Add("@Nama", vM_AccountEmployee.Nama);
            parameters.Add("@posisi", vM_AccountEmployee.Posisi);
            parameters.Add("@Email", vM_AccountEmployee.Email);
            parameters.Add("@PhoneNumber", vM_AccountEmployee.PhoneNumber);
            parameters.Add("@BirthDate", vM_AccountEmployee.BirthDate);
            parameters.Add("@Password", vM_AccountEmployee.Passwords);
            var result = connection.Execute(spName, parameters, commandType: CommandType.StoredProcedure);

            return(result);
        }
Ejemplo n.º 9
0
        public ActionResult Login(VM_AccountEmployee vM)
        {
            HttpResponseMessage response = client.PostAsJsonAsync("Login/Login", vM).Result;
            var readTask = response.Content.ReadAsStringAsync();

            readTask.Wait();
            var respondTask  = readTask.Result;
            var responseTask = client.GetAsync("Employees/");

            responseTask.Wait();

            var result = responseTask.Result;

            if (result.IsSuccessStatusCode)
            {
                var read = result.Content.ReadAsAsync <IList <Employee> >();
                read.Wait();
                var id = read.Result.Where(a => a.Email == vM.Email).FirstOrDefault().EmployeeId;


                return(RedirectToAction("Index", "Employees", new { id }));
            }
            return(View());
        }