Basically I want users to reset password after initial login. I just need help with the UPDATE method.Updating password in database.
My controller
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using jury_service.Models;
namespace jury_service.Controllers
{
public class NewpasswordController : Controller
{
public ActionResult Index()
{
return View();
}
[HttpPost] *blueerrorlinehere
public ActionResult CreatePassword(CreateNewInfo login)
{
if (ModelState.IsValid)
{
var uname = login.UpdateUser(login);
var newpassword = login.UpdateUser(login);
var confirmnewpassword = login.UpdateUser(login);
if (uname != null)
{
if
(newpassword == confirmnewpassword)
{
return Redirect("");
}
else
{
ModelState.AddModelError("Error", "Passwords Must Match");
}
return View();
}
}
}
public ActionResult CreatePassword()
{
return View();
}
public ActionResult CreateNewInfo()
{
return View();
}
}
}
View
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
using System.Data.Entity;
using System.Web.Mvc;
using Newtonsoft.Json;
using System.Net;
using System.Web.Providers.Entities;
using jury_service.CommonService;
namespace jury_service.Models
{
public class CreateNewInfo : BaseModel
{
[Display(Name = "Username")]
[Required]
public string uname { get; set; }
[Display(Name = "New Password")]
[Required]
public string newpassword { get; set; }
[Display(Name = "Confirm Password")]
[Required]
public string confirmnewpassword { get; set; }
public CreateNewInfo(): base(new WebClient(), new CommonClient(), new Factory())
{
}
public FCC_Users UpdateUser(CreateNewInfo login)
{
try
{
Client.Headers.Add(HttpRequestHeader.ContentType, "application/json");
return JsonConvert.DeserializeObject<FCC_Users>(Client.UploadString(new Uri(Properties.Settings.Default.Api_Url + "Info" + "?infoname=" + login.uname )));
}
catch (Exception ex)
{
return null;
}
}
}
}
What I have tried:
Error:
[HttpPost] *blueerrorlinehere
public ActionResult CreatePassword(CreateNewInfo login)
Error 1 'jury_service.Controllers.NewpasswordController.CreatePassword(jury_service.Models.CreateNewInfo)': not all code paths return a value
Error line within the parentheses
return JsonConvert.DeserializeObject<fcc_users>(Client.UploadString(new Uri(Properties.Settings.Default.Api_Url + "Info" + "?infoname=" + login.uname )));
Error message
No overload for method 'UploadString' takes 1 arguments