// PUT: api/Child/5 public HttpResponseMessage Put(int id, [FromBody] child value) { try { using (QLMamNonEntities db = new QLMamNonEntities()) { child s = db.children.SingleOrDefault(b => b.id == id); if (s != null) { s.name = value.name; s.birthday = value.birthday; s.gender = value.gender; s.status = value.status; s.id_customer = value.id_customer; db.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.OK, new childDTO(s.id, s.name, s.birthday.ToString(), (int)(s.gender), (int)(s.status), Convert.ToInt64(s.id_customer)))); } else { return(null); } } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message)); } }
public async Task <IActionResult> Putchild([FromRoute] string id, [FromBody] child child) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != child.color2) { return(BadRequest()); } _context.Entry(child).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!childExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
static void Main() { child d = new child(); d.show(); Console.Read(); }
static void Main(string[] args) { child obj = new child(); obj.print1(); Console.ReadKey(); }
/// <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 ActionResult DeleteChild(int id) { try { List <ChildGroupRelation> selectedGroups = operations.GetGroupInfoFromChild(id); int price = 0; if (selectedGroups.Count == 2) { price = 1000; child child = operations.FindCaretakerByChild(id); operations.DecreaseCaretakerDebt(child.caretaker_id, price); } else if (selectedGroups.Count == 1) { price = 700; child child = operations.FindCaretakerByChild(id); operations.DecreaseCaretakerDebt(child.caretaker_id, price); } operations.DeleteChildGroup(id); operations.DeleteChild(id); return(RedirectToAction("Child")); } catch (Exception) { string message = "Det går inte att ta bort den anställda, vänligen försök igen."; return(RedirectToAction("Error", "Home", new { message = message })); } }
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; }); }
void Method() { Program p1 = new Program(); p1.printFirstName(); // this works child c1 = new child(); p1.printFirstName(); // this gives your compiler error }
public ActionResult DeleteConfirmed(string id) { child child = db.children.Find(id); db.children.Remove(child); db.SaveChanges(); return(RedirectToAction("Index")); }
static void Main(string[] args) { child ch = new child(); ch.printFirstName(); ch.getMiddleName(); ch.printLastName(); Console.Read(); }
public ActionResult Edit([Bind(Include = "color2,location,Description")] child child) { if (ModelState.IsValid) { db.Entry(child).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(child)); }
//מוסיפה ילד חדש public static bool NewChild(child newChild) { if (volunteeringET.child.FirstOrDefault(child => child.tz == newChild.tz) == null) { volunteeringET.child.Add(newChild); volunteeringET.SaveChanges(); return(true); } return(false); }
public ManageChildrenViewModel() { SearchCommand = new RelayCommand <string>((p) => { return(true); }, (p) => { if (p == null) { return; } List <child> SearchedChildren = DataProvider.Ins.DB.children.Where <child> (x => x.name.Contains(p)).Join( DataProvider.Ins.DB.parents, d => d.id_parent, f => f.id, (d, f) => d ).ToList(); LoadData(SearchedChildren); }); DeleteCommand = new RelayCommand <int>((p) => { return(true); }, async(p) => { if (p == null) { return; } var CurrentWindow = Application.Current.MainWindow as MetroWindow; var mySettings = new MetroDialogSettings() { AffirmativeButtonText = "Yes", NegativeButtonText = "No", FirstAuxiliaryButtonText = "Ok", ColorScheme = CurrentWindow.MetroDialogOptions.ColorScheme }; var mySettings2 = new MetroDialogSettings() { AffirmativeButtonText = "Ok", NegativeButtonText = "No", FirstAuxiliaryButtonText = "Ok", ColorScheme = CurrentWindow.MetroDialogOptions.ColorScheme }; MessageDialogResult mR = await CurrentWindow.ShowMessageAsync("Hello!", "Do you really want to delete this child information ?", MessageDialogStyle.AffirmativeAndNegative, mySettings); if (mR == MessageDialogResult.Affirmative) { child DeleteChild = DataProvider.Ins.DB.children.Where(x => x.id == p).ToArray()[0]; DataProvider.Ins.DB.children.Remove(DeleteChild); DataProvider.Ins.DB.SaveChanges(); await CurrentWindow.ShowMessageAsync("Hello!", "Deleted Successfully.", MessageDialogStyle.Affirmative, mySettings2); LoadData(); } }); ListChildren = new ObservableCollection <ChildrenData>(); LoadData(); }
public ActionResult Create([Bind(Include = "color2,location,Description")] child child) { if (ModelState.IsValid) { db.children.Add(child); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(child)); }
public async Task <IActionResult> Postchild([FromBody] child child) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.child.Add(child); await _context.SaveChangesAsync(); return(CreatedAtAction("Getchild", new { id = child.color2 }, child)); }
public EditChildrenViewModel() { LoadClasses(); LoadConditions(); SaveCommand = new RelayCommand <object>((p) => { return(true); }, async(p) => { var mySettings = new MetroDialogSettings() { AffirmativeButtonText = "Ok", NegativeButtonText = "Go away!", FirstAuxiliaryButtonText = "Cancel", ColorScheme = Window.MetroDialogOptions.ColorScheme }; Child.name = this._childrenName; Child.sex = this._sex; Child.birthdate = this._birthDate; Child.nickname = this._nickName; Child.id_class = DataProvider.Ins.DB.classes.Where(x => x.name == selectedClass).ToArray()[0].id; Child.id_condition = DataProvider.Ins.DB.conditions.Where(x => x.name == selectedCondition).ToArray()[0].id; DataProvider.Ins.DB.SaveChanges(); ManageChildrenViewModel.Ins.LoadData(); EnrollViewModel.LoadClasses(); await Window.ShowMessageAsync("Hello!", "Saved changes successfully.", MessageDialogStyle.Affirmative, mySettings); Window.Close(); }); foreach (Window window in Application.Current.Windows) { if (window.Name == "EditChildrenWindow") { this.Window = window as EditChildren; break; } } Child = DataProvider.Ins.DB.children.Where(x => x.id == Window.id).Join( DataProvider.Ins.DB.parents, d => d.id_parent, f => f.id, (d, f) => d ).ToArray()[0]; this.selectedClass = DataProvider.Ins.DB.classes.Where(x => x.id == Child.id_class).ToArray()[0].name; this._childrenName = Child.name; this._nickName = Child.nickname; this._birthDate = Child.birthdate; this._sex = Child.sex; this._motherName = Child.parent.Mothername; this._fatherName = Child.parent.FatherName; if (DataProvider.Ins.DB.conditions.Where(x => x.id == Child.id_condition).Count() > 0) { this.selectedCondition = DataProvider.Ins.DB.conditions.Where(x => x.id == Child.id_condition).ToArray()[0].name; } }
// GET: children/Delete/5 public ActionResult Delete(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } child child = db.children.Find(id); if (child == null) { return(HttpNotFound()); } return(View(child)); }
public void ThemHanhKhach(child HanhKhach) { DateTime temp = DateTime.ParseExact(HanhKhach.childBirthday, "dd/MM/yyyy", CultureInfo.InvariantCulture); object[] sqlparams = new SqlParameter[] { new SqlParameter("@LoaiHanhKhach", "Trẻ em"), new SqlParameter("@GioiTinh", HanhKhach.childSex), new SqlParameter("@HoTen", HanhKhach.childName), new SqlParameter("@NgaySinh", temp), new SqlParameter("@MaHanhLi", HanhKhach.childBaggage), }; context.Database.ExecuteSqlCommand("exec ThemHanhKhach @LoaiHanhKhach,@GioiTinh,@HoTen,@NgaySinh,@MaHanhLi", sqlparams); }
// GET: api/Child/5 public childDTO Get(int id) { using (QLMamNonEntities db = new QLMamNonEntities()) { child s = db.children.SingleOrDefault(x => x.id == id); if (s != null) { return(new childDTO(s.id, s.name, s.birthday.ToString(), (int)(s.gender), (int)(s.status), Convert.ToInt64(s.id_customer))); } else { return(null); } } }
static void Main(string[] args) { Adult []a=new Adult[2]; a[0] = new Adult() { FName="Joe" ,LName="Smith"}; a[1] = new child() { FName = "Sally", LName = "John" }; foreach(var item in a) { Console.WriteLine($"{item.FName} {item.LName}"); } }
// // GET: children/Delete/5 // public ActionResult Delete(string id) // { // if (id == null) // { // return new HttpStatusCodeResult(HttpStatusCode.BadRequest); // } // child child = db.children.Find(id); // if (child == null) // { // return HttpNotFound(); // } // return View(child); //} //// POST: children/Delete/5 //[HttpPost, ActionName("Delete")] //[ValidateAntiForgeryToken] //public ActionResult DeleteConfirmed(string id) //{ // child child = db.children.Find(id); // db.children.Remove(child); // db.SaveChanges(); // return RedirectToAction("Index"); //} public child Save(child child) { if (child.location != null) { //db.Entry(child).State = EntityState.Modified; db.Save(child); } else { //db.children.(child); db.Save(child); } //db.SaveChanges(); return(child); }
// GET: children/Details/5 public ActionResult Details(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } child child = db.children.SingleOrDefault(c => c.location == id); if (child == null) { // if HttpNotfound return(View("Error")); } return(View(child)); }
// POST: api/Fixture public HttpResponseMessage Post([FromBody] child obj) { try { using (QLMamNonEntities db = new QLMamNonEntities()) { db.children.Add(obj); db.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.Created, obj)); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message)); } }
// // GET: children/Create // public ActionResult Create() //{ // return View(); //} // public ViewResult Details(int v) // { // throw new NotImplementedException(); // } // // POST: children/Create // // To protect from overposting attacks, please enable the specific properties you want to bind to, for // // more details see https://go.microsoft.com/fwlink/?LinkId=317598. // [HttpPost] //[ValidateAntiForgeryToken] //public ActionResult Create([Bind(Include = "color2,location,Description")] child child) //{ // if (ModelState.IsValid) // { // db.children.Add(child); // db.SaveChanges(); // return RedirectToAction("Index"); // } //return View(child); //} // GET: children/Edit/5 public ActionResult Edit(string destinationLocation) { if (destinationLocation == null) { return(View("Error")); } // child child = db.children.Find(id); // new code unit testing //string destinationLocation = ""; child child = db.children.SingleOrDefault(c => c.location == destinationLocation); if (child == null) { return(View("Error")); } return(View(child)); }
// DELETE: api/Child/5 public HttpResponseMessage Delete(int id) { try { using (QLMamNonEntities db = new QLMamNonEntities()) { child s = db.children.SingleOrDefault(x => x.id == id); db.children.Remove(s); db.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.OK)); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message)); } }
//מחזירה ילד ע"פ ת.ז public HttpResponseMessage GetChild(int id) { //Request.Headers.Contains("id"); HttpResponseMessage response; child c = VolunteeringET.child.Find(id); if (c == null) { response = Request.CreateResponse(); response.StatusCode = HttpStatusCode.NotFound; } else { response = Request.CreateResponse(ChildBL.GetChildById(id)); response.StatusCode = HttpStatusCode.OK; } return(response); }
//ביטול קבוע של התנדבות public static bool CancellationIndividualdVolunteering(int volunteerOfChildID) { volunteerOfChild voc = volunteeringET.volunteerOfChild.Find(volunteerOfChildID); if (voc != null) { child c = volunteeringET.child.Find(voc.childId); family f = volunteeringET.family.Find(c.familyId); volunteer v = volunteeringET.volunteer.Find(voc.volunteerId); string subject = "ביטול התנדבות חד פעמי"; string mail = f.mail; string body = "שלום וברכה!, מתנצלים אך נראה שהמתנדבת " + v.firstName + " " + v.lastName + " אינה יכולה להתנדב ביום " + voc.day + " בשעה: " + voc.hour + "בצורה חד פעמית ,סליחה ותודה מראש על ההבנה"; GlobalBL.SendEmail(mail, subject, body); return(true); } return(false); }
//מקבלת ילד לפי תעודת זהות ומשנה לו את הסטטוס לפעיל public static bool UpdateTheStatus(int id) { child c = volunteeringET.child.Find(id); if (c != null) { c.status = EStatusChild.ACTIVE.ToString(); string password = GlobalBL.ToRaffleAndPostUserNameAndPassword(); family f = volunteeringET.family.Find(c.familyId); f.password = password; f.userName = f.lastName + f.phone; volunteeringET.SaveChanges(); string body = "ברכות, כעת נרשמת בהצלחה לידיד לילד ותוכל להשתמש במגוון שירותי האתר , הסיסמא ושם המשתמש שאיתם תוכל להיכנס לאתר הם: " + "your password is: " + f.password + f.userName; string subject = "בקשה להרשמה לאתר ידיד לילד"; GlobalBL.SendEmail(f.mail, subject, body); return(true); } 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(); }
static void Main(string[] args) { parent p = new parent(); // p.common(); child c = new child(); // c.common(); parent pp = new child(); pp.common(); // (c as parent).common(); Console.ReadKey(); }