public async Task <IActionResult> Edit(Guid id, [Bind("Person_Id,duration,EndDate,IsEnd,Id,Ref,Price,Payement_date")] CustomerPayement customerPayement) { if (id != customerPayement.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(customerPayement); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CustomerPayementExists(customerPayement.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["Person_Id"] = new SelectList(_context.Customers, "Person_Id", "Person_Id", customerPayement.Person_Id); return(View(customerPayement)); }
public async Task <IActionResult> Create([Bind("Person_Id,duration,EndDate,IsEnd,Id,Ref,Price,Payement_date")] CustomerPayement customerPayement) { if (ModelState.IsValid) { _context.Add(customerPayement); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["Person_Id"] = new SelectList(_context.Customers, "Person_Id", "Person_Id", customerPayement.Person_Id); return(View(customerPayement)); }
public void AddNew(CustomerPayement payement) { if (payement.Id == Guid.Empty) { payement.EndDate = payement.Payement_date.AddMonths(1); _uowPayment.Entity.InsertElement(payement); _uowPayment.Save(); ResetRestIsEndForTrue(payement.Person_Id); } else { throw new Exception("IdShould be identity"); } }
public void UpdateElement(Guid id, CustomerPayement payement) { if (id == payement.Id) { DateTime endDate = payement.Payement_date.AddMonths(payement.duration); payement.EndDate = endDate; _uowPayment.Entity.UpdateElement(payement); _uowPayment.Save(); ResetRestIsEndForTrue(payement.Person_Id); } else { throw new Exception("Id category dosen't belong to the new category"); } }
public IActionResult Create(CustomerPayement collection) { try { // TODO: Add insert logic here collection.Id = Guid.Empty; _repositoryPayement.AddNew(collection); // var cust = _repositoryPayement.GetElements(p => p.Person_Id == collection.Person_Id); return(RedirectToAction("Details", "Customers", new { id = collection.Person_Id }).WithSuccess("Ajouter", "vous avez ajouté avec succès ")); } catch { return(View("Error")); } }
public IActionResult Edit(Guid id, CustomerPayement customerPayement) { try { // TODO: Add update logic here if (ModelState.IsValid) { _repositoryPayement.UpdateElement(id, customerPayement); return(RedirectToAction("Index").WithSuccess("Modifier", "vous avez modifié avec succès ")); } return(View(customerPayement).WithDanger("Modifier", "Operation de modifier est échouer")); } catch { return(View("Error")); } }