Exemplo n.º 1
0
        public async Task <ActionResult> Edit(string user_id)
        {
            if (user_id != null)
            {
                UserCredentialsUpdateViewModel model = new UserCredentialsUpdateViewModel();
                var postTask = await client.GetAsync("/api/UserCredentials/View/?user_id=" + user_id);

                model = await postTask.Content.ReadAsAsync <UserCredentialsUpdateViewModel>();

                if (model != null)
                {
                    return(View("Edit", model));
                }
                else
                {
                    UserCredentialsIndexViewModel data = new UserCredentialsIndexViewModel();
                    ViewBag.Error = "No User Credentials Found !";
                    return(View("Index", data));
                }
            }

            return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
        }
Exemplo n.º 2
0
        public async Task <ActionResult> Update(UserCredentialsUpdateViewModel data)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    data.active           = true;
                    data.modifiedDateTime = DateTime.Now;
                    data.modifiedBy       = Session["user_id"].ToString();
                    var postTask = await client.PostAsJsonAsync("/api/UserCredentials/Update", data);

                    if (postTask.IsSuccessStatusCode)
                    {
                        return(Json(true, JsonRequestBehavior.DenyGet));
                    }
                }
                catch (Exception e)
                {
                    return(Json(e.Message, JsonRequestBehavior.DenyGet));
                }
            }

            return(Json(false, JsonRequestBehavior.DenyGet));
        }