using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Script.Services; using System.Web.Services; using Common; /// /// Summary description for UpdateOperatorLogin /// [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [ScriptService] public class UpdateOperatorLogin : WebService { [WebMethod] public bool UpdatePassword(int pk, string value) { HttpContext.Current.Trace.Warn("UpdatePassword", string.Format("pk: {0}, value: {1}", pk, value)); using (var db = new DataModel()) { var operatorLogin = db.OperatorLogins.FirstOrDefault(f => f.OperatorLoginId == pk); if (operatorLogin == null) throw new Exception("Operator not found"); if (string.IsNullOrEmpty(value) || value.Length < 4) throw new Exception("Password length too short"); operatorLogin.Password = value; db.SaveChanges(); } return true; } [WebMethod] public bool UpdateRole(int pk, int value) { HttpContext.Current.Trace.Warn("UpdateRole", string.Format("pk: {0}, value: {1}", pk, value)); using (var db = new DataModel()) { var operatorLogin = db.OperatorLogins.FirstOrDefault(f => f.OperatorLoginId == pk); if (operatorLogin == null) throw new Exception("Operator not found"); operatorLogin.OperatorRoleId = value; db.SaveChanges(); } return true; } }