public int creareBeneficiar() { var benef = new Beneficiar(); db.Beneficiars.Add(benef); return(benef.ID); }
public async Task <IActionResult> Edit(int id, [Bind("Id,FirstName,MiddleName,LastName,DateOfBirth,PlaceOfBirth,RecordPlace,RecordNumber,Nationality,sect,Insured,PhoneNumber,SocialStatus,HealthStatus,HandicapType")] Beneficiar beneficiar) { if (id != beneficiar.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(beneficiar); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BeneficiarExists(beneficiar.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction("ChooseField", "Home")); //return RedirectToAction(nameof(Index)); } return(View(beneficiar)); }
public async Task <IActionResult> Create([Bind("location,type,rent,roomnumber,misses")] Address address) { if (ModelState.IsValid) { string missings = ""; if (address.misses != null) { for (int i = 0; i < address.misses.Count(); i++) { missings += address.misses[i] + ","; } } address.missings = missings; if (TempData["Field"] != null) { address.BeneficiarID = (int)TempData.Peek("BenId"); _context.Add(address); await _context.SaveChangesAsync(); return(RedirectToAction("ChooseField", "Home")); } // CreateModel model = TempData["model"] as CreateModel; CreateModel model = TempData.Get <CreateModel>("model"); model.address = address; TempData.Put <CreateModel>("model", model); // TempData["model"] = model; //Beneficiar b = TempData["Beneficiar"] as Beneficiar; Beneficiar b = model.beneficiar; string n = b.FirstName; string a = model.address.location; if (b.SocialStatus.Equals("Married") || b.SocialStatus.Equals("Dead")) { return(Redirect("~/Beneficiars/New/AddingInfo/Wives")); } //else if(b.SocialStatus.Equals("Single")) // return Redirect("~/Beneficiars/New/AddingInfo/Belongings"); else { return(Redirect("~/Beneficiars/New/AddingInfo/Children")); } } return(View(address)); }
//public IActionResult EditBeneficiary(int? BeneficiarID) { // if (BeneficiarID == null) BeneficiarID = (int)TempData.Peek("BenId"); // TempData["BenId"] = BeneficiarID; // Beneficiar b = _context.Beneficiars.Where(b => b.Id == BeneficiarID).FirstOrDefault(); // TempData["Name"] = b.FullName; // ViewData["Name"] += b.FullName; // //CreateModel model = new CreateModel(); // //model.beneficiar = b; // b.wife = _context.Wives.Where(b => b.BeneficiarID == BeneficiarID).FirstOrDefault(); // b.wife.disease = _context.diseases.Where(d => d.WifeID == b.wife.Id).FirstOrDefault(); // b.wife.work = _context.works.Where(w => w.WifeID == b.wife.Id).FirstOrDefault(); // b.work = _context.works.Where(b => b.BeneficiarID == BeneficiarID).FirstOrDefault(); // b.disease = _context.diseases.Where(b => b.BeneficiarID == BeneficiarID).FirstOrDefault(); // b.address = _context.addresses.Where(b => b.BeneficiarID == BeneficiarID).FirstOrDefault(); // b.loan = _context.loans.Where(b => b.BeneficiarID == BeneficiarID).FirstOrDefault(); // b.belongings = _context.belongings.Where(b => b.BeneficiarID == BeneficiarID).FirstOrDefault(); // b.socialHelp = _context.socialHelps.Where(b => b.BeneficiarID == BeneficiarID).FirstOrDefault(); ; // return View(b); //} public IActionResult ChooseField(int?BeneficiarID) { if (BeneficiarID == null) { BeneficiarID = (int)TempData.Peek("BenId"); } TempData["BenId"] = BeneficiarID; Beneficiar b = _context.Beneficiars.Where(b => b.Id == BeneficiarID).FirstOrDefault(); TempData["Name"] = b.FullName; ViewData["Name"] += b.FullName; return(View()); }
public ContentResult Edit(int id, Proiect requestBeneficiar) { Beneficiar beneficiar = db.Beneficiars.Find(id); try { if (User.IsInRole("Administrator") || User.IsInRole("User")) { if (TryUpdateModel(beneficiar)) { beneficiar.Nume = requestBeneficiar.Beneficiar.Nume; beneficiar.Adresa = requestBeneficiar.Beneficiar.Adresa; beneficiar.CNP = requestBeneficiar.Beneficiar.CNP; beneficiar.SerieCI = requestBeneficiar.Beneficiar.SerieCI; beneficiar.NumarCI = requestBeneficiar.Beneficiar.NumarCI; beneficiar.Telefon = requestBeneficiar.Beneficiar.Telefon; beneficiar.Email = requestBeneficiar.Beneficiar.Email; beneficiar.PersoanaContact = requestBeneficiar.Beneficiar.PersoanaContact; beneficiar.TelefonPersoanaContact = requestBeneficiar.Beneficiar.TelefonPersoanaContact; db.SaveChanges(); TempData["message"] = "Detaliile beneficiarului au fost actualizate."; return(Content("Succes")); } else { return(Content("Eroare")); } } else { TempData["message"] = "Nu aveti drepturi pentru aceasta actiune."; return(Content("Eroare")); } } catch (Exception e) { TempData["message"] = "eroare" + e.ToString(); } return(Content("Eroare")); }
public async Task <IActionResult> Create([Bind("Id,FirstName,MiddleName,LastName,DateOfBirth,PlaceOfBirth,RecordPlace,RecordNumber,Nationality,sect,Insured,PhoneNumber,SocialStatus,HealthStatus,HandicapType")] Beneficiar beneficiar) { if (ModelState.IsValid) { TempData["Person"] = "Beneficiar"; TempData["Field"] = null; TempData["Field2"] = null; // _context.Add(beneficiar); // await _context.SaveChangesAsync(); //return RedirectToAction(nameof(Index)); TempData["Bid"] = beneficiar.Id; // TempData["Beneficiar"] = beneficiar; CreateModel createModel = new CreateModel(); createModel.beneficiar = beneficiar; //TempData["model"] = createModel; TempData.Put <CreateModel>("model", createModel); CreateModel userTemp = TempData.Get <CreateModel>("model"); string s = userTemp.beneficiar.FirstName; TempData["Name"] = beneficiar.FullName; if (beneficiar.HealthStatus != null && beneficiar.HealthStatus.Equals("Diseased")) { //return Redirect("~/Beneficiars/Create/" + beneficiar.Id + "/Diseases"); return(Redirect("~/Beneficiars/New/AddingInfo/Diseases")); } //return Redirect("~/Beneficiars/Create/" + beneficiar.Id + "/Works/Check"); ///////////////////////////////////////////////////////// /Check return(Redirect("~/Beneficiars/New/AddingInfo/Works/Create")); } return(View(beneficiar)); }