private async void CheckingAndAdding(MetroDialogSettings mySettings, MetroWindow CurrentWindow) { var controller = await MainViewModel.Ins.dialogCoordinator.ShowProgressAsync(MainViewModel.Ins, "Processing", "Proceessing all the things, please wait."); controller.SetIndeterminate(); if (DataProvider.Ins.DB.parents.Where(x => x.Mothername == this._motherName && x.FatherName == this._fatherName && x.address == this._address && x.phonenumber == this._phoneNumber).Count() > 0) { await Application.Current.Dispatcher.Invoke(async() => { await controller.CloseAsync(); await CurrentWindow.ShowMessageAsync("Hello!", "This parent is already in the database.", MessageDialogStyle.Affirmative, mySettings); }); return; } parent AddingParent = new parent(); AddingParent.FatherName = this._fatherName; AddingParent.Mothername = this._motherName; AddingParent.phonenumber = this._phoneNumber; AddingParent.address = this._address; DataProvider.Ins.DB.parents.Add(AddingParent); await Application.Current.Dispatcher.Invoke(async() => { await DataProvider.Ins.DB.SaveChangesAsync(); await controller.CloseAsync(); await CurrentWindow.ShowMessageAsync("Hello!", "Added succesfully.", MessageDialogStyle.Affirmative, mySettings); LoadData(); }); }
public void ValidateParentRegisterAccount_WithValidModel_ExpectValidNavigation() { Mock <HttpContextBase> moqContext = new Mock <HttpContextBase>(); Mock <HttpRequestBase> moqRequest = new Mock <HttpRequestBase>(); Mock <HttpPostedFileBase> moqPostedFile = new Mock <HttpPostedFileBase>(); moqRequest.Setup(r => r.Files.Count).Returns(0); moqContext.Setup(r => r.Request).Returns(moqRequest.Object); // Arrange var controller = new UserController(); var parent = new parent { fullname = "Trần Phú Hòa", username = "******", phone = "090 123 7654", email = "*****@*****.**", password = "******" }; controller.ControllerContext = new ControllerContext(moqContext.Object, new RouteData(), controller); var validationResults = TestModelHelper.ValidateModel(controller, parent); // Act var redirectRoute = controller.RegisterParent(parent) as RedirectToRouteResult; //Assert Assert.IsNotNull(redirectRoute); Assert.AreEqual("ConfirmEmail", redirectRoute.RouteValues["action"]); Assert.AreEqual("User", redirectRoute.RouteValues["controller"]); Assert.AreEqual(0, validationResults.Count); }
/// <summary> /// 为了解决泛型父子类 关系的实例进行转换 /// 协变,逆变;只能放在接口或者委托的泛型参数前面 /// 协变:out /// 只以做为返回值 /// 左边是父,右边是子 /// 逆变:in /// 只可以做为参数值 /// 左边是子,右边是父 /// </summary> public void Test() { { parent parent1 = new parent(); parent parent2 = new child(); //父类拥有子类的所有属性 child child1 = new child(); } { List <Worker> parentlist1 = new List <Worker>(); //List<Worker> parentlist2 = new List<Worker>(); //两个list 泛型实例不存在集成关系 // 为解决两个父子关系的实例采用协变进行; List <Worker> parentlist2 = new List <WorkBase>().Select(item => (Worker)item).ToList(); ///协变 out 处理左侧是父,右侧是子 IEnumerable <WorkBase> outList = new List <Worker>(); IMyOut <WorkBase> outMyList = new MyOut <Worker>(); //逆变 in 处理左侧是子,右侧是父 IMyIn <Worker> inList = new MyIn <WorkBase>(); //协变+逆变 IMyInOut <Worker, WorkBase> myInOut = new MyInOut <WorkBase, Worker>(); //协变 IMyInOut <Worker, WorkBase> myInOut2 = new MyInOut <Worker, Worker>(); //逆变 IMyInOut <Worker, WorkBase> myInOut3 = new MyInOut <WorkBase, WorkBase>(); } }
public EnrollViewModel() { this.BirthDate = DateTime.Now.ToString(); LoadClasses(); BrowseCommand = new RelayCommand <UserControl>((p) => true, (p) => { var dlg = new OpenFileDialog(); dlg.Title = "Choose profile picture"; dlg.InitialDirectory = ""; dlg.Filter = "All supported graphics|*.jpg;*.jpeg;*.png|" + "JPEG (*.jpg;*.jpeg)|*.jpg;*.jpeg|" + "Portable Network Graphic (*.png)|*.png"; dlg.Multiselect = false; if (dlg.ShowDialog() == true) { this.ImageURL = dlg.FileName; } }); EnrollCommand = new RelayCommand <UserControl>((p) => { return(true); }, async(p) => { var CurrentWindow = Application.Current.MainWindow as MetroWindow; var mySettings = new MetroDialogSettings() { AffirmativeButtonText = "Ok", FirstAuxiliaryButtonText = "Cancel", ColorScheme = CurrentWindow.MetroDialogOptions.ColorScheme }; parent addingParent = new parent(); addingParent.Mothername = this._motherName; addingParent.FatherName = this._fatherName; addingParent.address = this._address; addingParent.phonenumber = this._phoneNumber; child addingChild = new child(); addingChild.name = this._childrenName; addingChild.nickname = this._nickName; addingChild.sex = this._sex; addingChild.imageUrl = this.ImageURL; addingChild.birthdate = this._birthDate; addingChild.enrolldate = DateTime.Now; if (ChildrenName == null || NickName == null || MotherName == null || FatherName == null || Address == null || PhoneNumber == null || _className == null) { await CurrentWindow.ShowMessageAsync("Hello!", "Please fill in every blanks.", MessageDialogStyle.Affirmative, mySettings); return; } if (_className == "") { await CurrentWindow.ShowMessageAsync("Hello!", "Please fill in every blanks.", MessageDialogStyle.Affirmative, mySettings); return; } await Task.Factory.StartNew(() => CheckingAndAdding(addingParent, addingChild, CurrentWindow, mySettings)); this.Address = null; }); }
public ActionResult RegisterParent(parent parent) { parent.status = 2; model.parents.Add(parent); model.SaveChanges(); return(RedirectToAction("ConfirmEmail", "User")); }
void main() { Basket bsk = new Basket(); parent pnt = new parent(); Lemon lmn = new Lemon(); bsk.AddToBasket(lmn);// is this OK? }
public virtual void DoSum() { parent a = new parent(); a.x = this.x; a.y = this.y; a.sum(); }
static void Main(string[] args) { var Li = new parent("Li", 12); Console.WriteLine("Your name is: {0}", Li.name); Console.WriteLine("Your age is: {0}", Li.age); Li.SayHi(); }
public ActionResult DeleteConfirmed(string id) { parent parent = db.parents.Find(id); db.parents.Remove(parent); db.SaveChanges(); return(RedirectToAction("Index")); }
public void bug_incorrect_element_placement() { var x = new parent(); x.Y = 1; x.child2 = new child(); test(x, @"<root><parent Y=""1"" X=""0""><child1 /><child2 id=""0"" /><child3 /></parent></root>"); }
static void Main(string[] args) { parent p = new parent(); p.pub_i = 30; //p.int_i = 40; //p.ip_i = 50; //p.pri_i = 10; //p.pro_i = 20; }
public ActionResult Edit([Bind(Include = "parent_id,father_name,mother_name,parent_email_id,parent_phone_number")] parent parent) { if (ModelState.IsValid) { db.Entry(parent).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(parent)); }
public ActionResult Edit([Bind(Include = "parent_id,email,password,firstname,lastname,dob,phone,mobile,status")] parent parent) { if (ModelState.IsValid) { db.Entry(parent).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(parent)); }
public ActionResult Create([Bind(Include = "parent_id,father_name,mother_name,parent_email_id,parent_phone_number")] parent parent) { if (ModelState.IsValid) { db.parents.Add(parent); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(parent)); }
public ActionResult Edit([Bind(Include = "parentID,fathername,fatheremail,fathermobile,mothername,motheremail,mothermobile,emergencycontact,studentID")] parent parent) { if (ModelState.IsValid) { db.Entry(parent).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.studentID = new SelectList(db.students, "studentID", "StudentID", parent.studentID); return(View(parent)); }
// PUT: api/Parents/5 public bool Put(parent parent) { try { return(unitOfWork.ParentManager.UpdateEntity(parent)); } catch { return(false); } }
public ActionResult Create([Bind(Include = "parent_id,email,password,firstname,lastname,dob,phone,mobile,status")] parent parent) { if (ModelState.IsValid) { db.parents.Add(parent); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(parent)); }
public void complex_class_with_attributes_processed() { var x = new parent(); test(x, @"{child1: null, child3: null, X: 0, }"); x.Y = 1; test(x, "{Y: 1, child1: null, child3: null, X: 0, }"); x.child2 = new child(); test(x, "{Y: 1, child1: null, child2: {id: 0, }, child3: null, X: 0, }"); x.child2.id2 = 3; test(x, "{Y: 1, child1: null, child2: {id: 0, id2: 3, }, child3: null, X: 0, }"); }
public void complex_class_with_attributes_processed() { var x = new parent(); test(x, @"<root><parent X=""0""><child1 /><child3 /></parent></root>"); x.Y = 1; test(x, @"<root><parent Y=""1"" X=""0""><child1 /><child3 /></parent></root>"); x.child2 = new child(); test(x, @"<root><parent Y=""1"" X=""0""><child1 /><child2 id=""0"" /><child3 /></parent></root>"); x.child2.id2 = 3; test(x, @"<root><parent Y=""1"" X=""0""><child1 /><child2 id=""0"" id2=""3"" /><child3 /></parent></root>"); }
public void complex_class_with_attributes_processed() { var x = new parent(); test(x, @"{""child1"": null, ""child3"": null, ""X"": 0}"); x.Y = 1; test(x, @"{""Y"": 1, ""child1"": null, ""child3"": null, ""X"": 0}"); x.child2 = new child(); test(x, @"{""Y"": 1, ""child1"": null, ""child2"": {""id"": 0}, ""child3"": null, ""X"": 0}"); x.child2.id2 = 3; test(x, @"{""Y"": 1, ""child1"": null, ""child2"": {""id"": 0, ""id2"": 3}, ""child3"": null, ""X"": 0}"); }
// GET: parents/Details/5 public ActionResult Details(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } parent parent = db.parents.Find(id); if (parent == null) { return(HttpNotFound()); } return(View(parent)); }
//GET : /Parents/ParentsDetails public ActionResult ParentsDetails(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } parent parentdetails = db.parents.Find(id); if (parentdetails == null) { return(HttpNotFound()); } return(View(parentdetails)); }
// POST: api/Parents public bool Post(parent parent) { var id = unitOfWork.ParentManager.MaxId(parent); for (int i = 0; true; i++) { if (unitOfWork.ParentManager.GetByID(id) == null) { parent.id = id; return(unitOfWork.ParentManager.AddEntity(parent)); } id++; } }
// GET: parents/Edit/5 public ActionResult Edit(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } parent parent = db.parents.Find(id); if (parent == null) { return(HttpNotFound()); } ViewBag.studentID = new SelectList(db.students, "studentID", "studentID", parent.studentID); return(View(parent)); }
public qTrie <Key> change(Key k, Func <bool> f) { throw new NotImplementedException(); #if NYI //let len = Key.length k in var len = k.Length; //let rec loop n {subs} = //let c = Key.nth_token k n in //if n + 1 = len then found subs c else find subs n c Func < int, and found parent c = Tokens.change parent c(function | None->f None >> | init | Some t->Some { t with data = f t.data })
[ActionName("Delete")] //lw mktbtha4 he3tbrha overload public ActionResult ConfirmDelete(int id) { try { parent data = db.parent.Find(id); db.parent.Remove(data); db.SaveChanges(); return(RedirectToAction("index")); } catch (Exception ex) { ViewBag.parentgender = new SelectList(db.SchoolGender, "id", "gender"); ViewBag.parentcity = new SelectList(db.parentcity, "id", "city"); return(View()); } }
public JsonResult editProfile(string data) { int parentId = int.Parse(Session["UserID"].ToString()); string message; var status = HttpStatusCode.OK; JObject parent = JObject.Parse(data); parent pr = db.parents.Find(parentId); pr.fullname = parent["fullname"].ToString(); pr.username = parent["username"].ToString(); pr.address = parent["address"].ToString(); pr.phone = parent["phone"].ToString(); db.SaveChanges(); message = "Cập nhật thông tin thành công "; var response = new { message = message, status = status }; return(Json(response, JsonRequestBehavior.AllowGet)); }
public bool loinpar(parent par) { SqlConnection con = new SqlConnection(@"Data Source=WIN-L8SRCUH9LF2\JACK;Initial Catalog=StudentroomDB;Persist Security Info=True;User ID=sa;pwd=720713"); SqlCommand cmd = con.CreateCommand(); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "dbo.pro_loginpar"; cmd.Parameters.Add("@parName", SqlDbType.VarChar, 50).Value = par.Name; cmd.Parameters.Add("@parpwd", SqlDbType.VarChar, 15).Value = par.Pwd; //返回值 SqlParameter parret = new SqlParameter("@retvalues", SqlDbType.Int); parret.Direction = ParameterDirection.ReturnValue; int ret = 0; cmd.Parameters.Add(parret); try { con.Open(); cmd.ExecuteNonQuery(); ret = (int)parret.Value; } catch (Exception ex) { Console.WriteLine(ex.Message); } finally { con.Close(); con.Dispose(); } if (ret == 1) { return(true); } else { return(false); } }
static void Main(string[] args) { interfaceSample i1 = new Implemntation(); i1.SampleInterface(); parent p = new parent(); child c = new child(); Console.WriteLine("calling from parent class"); c.display(); c.display1(); Console.WriteLine("From parent class"); p.display(); def d = new def(); sub s = new sub(); d.calc(); s.calc(); Console.ReadLine(); }
public ActionResult RegisterParent(parent parent /*, string password*/) { string password = ""; var parentEmail = model.parents.FirstOrDefault(x => x.email == parent.email || x.username == parent.username); if (parentEmail == null) { parent.status = 2; parent.password = commonService.hash(parent.password); parent.dateRegist = DateTime.Now; model.parents.Add(parent); model.SaveChanges(); return(RedirectToAction("ConfirmEmail", "User")); } else { ViewBag.Er = "Username hoặc email đã tồn tại !"; return(View("Register")); } }
: super(parent, labelProvider, contentProvider) { }
: super(parent, treeStyle, new PatternFilter(), true) {