public async Task <ActionResult <Studant> > Put( [FromServices] DataContext context, int id, [FromBody] Studant model) { if (id != model.Id) { return(NotFound(new { message = "Aluno não encontrado!" })); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { context.Entry(model).State = EntityState.Modified; await context.SaveChangesAsync(); return(model); } catch (DbUpdateConcurrencyException) { return(BadRequest(new { message = "Não foi possível atualizar este cadastro!" })); } }
public void ShouldReturnErrorWhenActiveSubscription() { var name = new Name("bruce", "waui"); var document = new Document("98532836038", EDocumentType.CPF); var email = new Email("*****@*****.**"); var studant = new Studant(name, document, email); Assert.Fail(); }
public JsonResult DeleteStudant(Studant studant) { if (studant == null) { return(Json(new { Message = "Erro", HasError = true }, JsonRequestBehavior.AllowGet)); } var dao = new StudantDAO(); var message = dao.deleteStudant(studant); return(Json(new { Message = message }, JsonRequestBehavior.AllowGet)); }
public async Task <ActionResult <Studant> > Post( [FromServices] DataContext context, [FromBody] Studant model) { if (ModelState.IsValid) { context.Studants.Add(model); await context.SaveChangesAsync(); return(model); } else { return(BadRequest(ModelState)); } }
public JsonResult ListStudant(Studant studant) { if (studant == null) { return(Json(new { Message = "Error", HasError = true }, JsonRequestBehavior.AllowGet)); } var dao = new StudantDAO(); var List = dao.ListStudant(); if (!List.Any()) { return(Json(new { Message = "No entry found" }, JsonRequestBehavior.AllowGet)); } return(Json(List, JsonRequestBehavior.AllowGet)); }
public string deleteStudant(Studant studant) { using (var context = new CollegeContext()) { var result = context.Studants.FirstOrDefault(c => c.StudantId == studant.StudantId); if (result == null) { return("Error"); } context.Studants.Remove(result); context.SaveChanges(); return("Sucess"); } }
public string UpdateStudant(Studant studant) { using (var context = new CollegeContext()) { var result = context.Studants.FirstOrDefault(c => c.StudantId == studant.StudantId); if (result == null) { return("Error"); } result.StudantName = studant.StudantName; //result.SubjectId = studant.SubjectId; context.SaveChanges(); return("Sucess"); } }
public ICommandResult Handle(CreateBoletoSubscriptionCommand command) { if (_repository.DocumentExists(command.Document)) { AddNotification("Document", "Este CPF já está em uso"); } if (_repository.EmailExists(command.Email)) { AddNotification("Document", "Este CPF já está em uso"); } var name = new Name(command.FirstName, command.LastName); var document = new Document(command.Document, EDocumentType.CPF); var email = new Email(command.Email); var address = new Address(command.Street, command.Number, command.Neighborhood, command.City, command.State, command.Country, command.ZipCode); var studant = new Studant(name, document, email); var subscription = new Subscription(DateTime.Now.AddMonths(1)); var payment = new BoletoPayment(command.BarCode, command.BoletoNumber, command.PaidDate, command.ExpireDate, command.Total, command.TotalPaid, command.Payer, new Document(command.PayerDocument, command.PayerDocumentType), address, email ); subscription.AddPayment(payment); studant.AddSubscription(subscription); AddNotifications(name, document, email, address, studant, subscription); _repository.CreateSubscription(studant); return(new CommandResult(true, "Assinatura realizada com sucesso!")); }
public string AddStudant(Studant studant) { using (var context = new CollegeContext()) { try { if (context.Studants.FirstOrDefault(x => x.RegistrationNumber == studant.RegistrationNumber) != null) { return("Registration number is already in the database"); } context.Studants.Add(studant); context.SaveChanges(); } catch (System.Exception) { return("Error"); } return("Sucess"); } }
public override bool Equals(object obj) { Studant other = obj as Studant; return(Number.Equals(other.Number)); }
public void CreateSubscription(Studant studant) { }