public void InsertStudent(Entities.Student student) { string connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["UPCConnectionString"].ConnectionString; // define INSERT query with parameters string query = "INSERT INTO Students (Code, Name, Age, GradeAverage) " + "VALUES (@Code, @Name, @Age, @GradeAverage) "; // create connection and command using (SqlConnection cn = new SqlConnection(connectionString)) using (SqlCommand cmd = new SqlCommand(query, cn)) { // define parameters and their values cmd.Parameters.Add("@Code", SqlDbType.VarChar, 15).Value = student.Code; cmd.Parameters.Add("@Name", SqlDbType.VarChar, 50).Value = student.Name; cmd.Parameters.Add("@Age", SqlDbType.Int).Value = student.Age; cmd.Parameters.Add("@GradeAverage", SqlDbType.Decimal).Value = student.GradeAverage; // open connection, execute INSERT, close connection cn.Open(); cmd.ExecuteNonQuery(); cn.Close(); } }
public IActionResult UpdateStudent(UpdateStudentReq req) { var studentEntity = new Entities.Student { IndexNumber = req.IndexNumber }; _studentContext.Attach(studentEntity); if (req.FirstName != null) { studentEntity.FirstName = req.FirstName; _studentContext.Entry(studentEntity).Property("FirstName").IsModified = true; } if (req.LastName != null) { studentEntity.LastName = req.LastName; _studentContext.Entry(studentEntity).Property("LastName").IsModified = true; } if (req.BirthDate != null) { studentEntity.BirthDate = req.BirthDate; _studentContext.Entry(studentEntity).Property("BirthDate").IsModified = true; } if (req.IdEnrollment != null) { studentEntity.IdEnrollment = Int32.Parse(req.IdEnrollment); _studentContext.Entry(studentEntity).Property("IdEnrollment").IsModified = true; } _studentContext.SaveChanges(); return(Ok($"Updated")); }
private void btnCreateStu_Click(object sender, EventArgs e) { if (ValidateForm()) { var logStudent = new Logic.Student(); if (!logStudent.ValidatePerson(txtDni.Text)) { var entStudent = new Entities.Student(txtDni.Text, txtName.Text, txtLastName.Text, txtProm.Text, preferences); try { logStudent.CreateStudent(entStudent); } catch (Exception ex) { MessageBox.Show(ex.Message); } this.Close(); } else { MessageBox.Show("LA PERSONA YA EXISTE."); CleanAndFocus(); } } }
public static void InsertStudent(StudentModel student, int userId) { using (var context = DataContext.GetContext()) { Debug.Assert(student.UserId != null, "student.UserId != null"); Debug.Assert(student.ExpectedGraduationYear != null, "student.ExpectedGraduationYear != null"); Debug.Assert(student.PrimaryDisabilityId != null, "student.PrimaryDisabilityId != null"); Debug.Assert(student.DateOfBirth != null, "student.DateOfBirth != null"); var newItem = new Entities.Student { UserId = student.UserId.Value, FirstName = student.FirstName, LastName = student.LastName, ExpectedGraduationYear = student.ExpectedGraduationYear.Value, PrimaryDisabilityID = student.PrimaryDisabilityId.Value, LocalEducationAgency = student.LocalEducationAgency, DateOfEntry = student.DateOfEntry, DateOfBirth = student.DateOfBirth.Value, SecondaryDisabilityID = student.SecondaryDisabilityId, CreatedBy = userId, CreatedOn = DateTime.Now, LastModifiedBy = userId, LastModifiedOn = DateTime.Now, Current = true }; context.Students.AddObject(newItem); context.SaveChanges(); } }
public void UpdateStudent(DEV_Library.Models.Student student) { Entities.Student currentStudent = _context.Student.Find(student.Id); Entities.Student updatedStudent = Mapper.MapStudent(student); _context.Entry(currentStudent).CurrentValues.SetValues(updatedStudent); }
public void UpdateStudent(Entities.Student student) { string connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["UPCConnectionString"].ConnectionString; // define INSERT query with parameters string storeProcedure = "usp_Students_UpdateStudent"; // create connection and command using (SqlConnection cn = new SqlConnection(connectionString)) using (SqlCommand cmd = new SqlCommand(storeProcedure, cn)) { cmd.CommandType = CommandType.StoredProcedure; // define parameters and their values cmd.Parameters.Add("@Id", SqlDbType.Int).Value = student.Id; cmd.Parameters.Add("@Code", SqlDbType.VarChar, 15).Value = student.Code; cmd.Parameters.Add("@Name", SqlDbType.VarChar, 50).Value = student.Name; cmd.Parameters.Add("@Age", SqlDbType.Int).Value = student.Age; cmd.Parameters.Add("@GradeAverage", SqlDbType.Decimal).Value = student.GradeAverage; // open connection, execute INSERT, close connection cn.Open(); cmd.ExecuteNonQuery(); cn.Close(); } }
public ActionResult Index() { List <StudentAddressVM> viewModels = new List <StudentAddressVM>(); StudentAddressBAL balObject = new StudentAddressBAL(); IQueryable <Entities.StudentAddress> entites = balObject.GetAll(); CountryBAL countryBAL = new CountryBAL(); IQueryable <Entities.Country> countries = countryBAL.GetAll(); StateBAL stateBAL = new StateBAL(); IQueryable <Entities.State> states = stateBAL.GetAll(); DistrictBAL DistrictObject = new DistrictBAL(); IQueryable <Entities.District> districts = DistrictObject.GetAll(); CityBAL CityObject = new CityBAL(); IQueryable <Entities.City> cities = CityObject.GetAll(); StudentBAL studentObject = new StudentBAL(); IQueryable <Entities.Student> students = studentObject.GetAll(); foreach (Entities.StudentAddress entity in entites) { StudentAddressVM viewModel = new StudentAddressVM(); viewModel.StudentId = entity.StudentId; viewModel.CurrentAddress = entity.CurrentAddress; viewModel.CurrentCountryId = entity.CurrentCountryId; viewModel.CurrentStateId = entity.CurrentStateId; viewModel.CurrentDistrictId = entity.CurrentDistrictId; viewModel.CurrentCityId = entity.CurrentCityId; viewModel.CurrentCountryName = countries.Where(c => c.CountryId == entity.CurrentCountryId).FirstOrDefault().CountryName; viewModel.CurrentStateName = states.Where(s => s.StateId == entity.CurrentStateId).FirstOrDefault().StateName; viewModel.CurrentDistrictName = districts.Where(c => c.DistrictId == entity.CurrentDistrictId).FirstOrDefault().DistrictName; viewModel.CurrentCityName = cities.Where(c => c.CityId == entity.CurrentDistrictId).FirstOrDefault().CityName; viewModel.PermentAddress = entity.PermentAddress; viewModel.PermentCountryId = entity.PermentCountryId; viewModel.PermentStateId = entity.PermentStateId; viewModel.PermentDistrictId = entity.PermentDistrictId; viewModel.PermentCityId = entity.PermentCityId; viewModel.PermentCountryName = countries.Where(c => c.CountryId == entity.PermentCountryId).FirstOrDefault().CountryName; viewModel.PermentStateName = states.Where(s => s.StateId == entity.PermentStateId).FirstOrDefault().StateName; viewModel.PermentDistrictName = districts.Where(c => c.DistrictId == entity.PermentDistrictId).FirstOrDefault().DistrictName; viewModel.PermentCityName = cities.Where(c => c.CityId == entity.PermentCityId).FirstOrDefault().CityName; viewModel.Status = entity.Status; viewModel.Remark = entity.Remark; Entities.Student student = students.Where(s => s.StudentId == entity.StudentId).FirstOrDefault(); viewModel.StudentFullNameWithTitle = string.Concat(student.Title, " ", student.FirstName, " ", student.MiddleName, " ", student.LastName); viewModels.Add(viewModel); } return(View(new GridModel <StudentAddressVM> { Data = viewModels })); }
public ICommandResult Handle(CreateBoletoSubscriptionCommand command) { //Fail Fast Validation command.Validate(); if (command.Invalid) { AddNotifications(command); return(new CommandResult(false, "Não foi possível realizar sua assinatura")); } //Verificar se Documento já está cadastrado if (_repository.DocumentExists(command.PayerDocument)) { AddNotification("Document", "Este CPF já está em uso"); } //Verificar se E-mail já está cadastrados if (_repository.EmailExists(command.PayerEmail)) { AddNotification("Email", "Este E-mail já está em uso"); } //Gerar os values Objects (VOs) var name = new Name(command.FirstName, command.LastName); var document = new Document(command.PayerDocument, EDocumentType.CPF); var email = new Email(command.PayerEmail); var address = new Address(command.Stret, command.Number, command.Neighborhood, command.City, command.State, command.Country, command.zipCode); //Gerar as entidades var student = new Entities.Student(name, email, document); var subscription = new Entities.Subscription(DateTime.Now.AddMonths(1)); var payment = new Entities.BoletoPayment(command.BarCode, command.BoletoNumber, command.Number, command.PaidDate, command.ExpireDate, command.Total, command.TotalPaid, command.Payer, new Document(command.Payer, command.PayerDocumentType), address, email); // Adiciona os Relacionamentos subscription.AddPayment(payment); student.AddSubscription(subscription); // Agrupa as validações AddNotifications(name, document, address, student, subscription, payment); //Checar as infos if (Invalid) { new CommandResult(false, "Assinatura realizada com suesso"); } // Salvar as validações _repository.CreateSubscription(student); //Enviar E-mail de boas vindas _emailService.Send(student.Name.ToString(), student.Email.Address, "Bem vindo ao Beludo", "Sua assinatura foi criada"); //Retornar informações return(new CommandResult(true, "Assinatura realizada com sucesso")); }
public static StudentViewModel MapStudentToStudentViewModel(Entities.Student student) { return(new StudentViewModel() { Id = student.Id, Name = student.Name }); }
public IActionResult putStudent(Entities.Student student) { _StudentContext.Add <Entities.Student>(student); _StudentContext.SaveChanges(); return(Ok(student)); }
public static void ApplyChanges(Models.Student toApply, ref Entities.Student result) { result.Forename = toApply.Forename; result.Surname = toApply.Surname; result.SwimEnglandNumber = toApply.SwimEnglandNumber; result.DateOfBirth = toApply.DateOfBirth; result.CurrentGradeNumber = toApply.CurrentGradeNumber; result.MedicalDetails = toApply.MedicalDetails; }
public static Models.Student GetStudent(Entities.Student _studentEntity) { return(new Models.Student() { ID = _studentEntity.ID, Forename = _studentEntity.Forename, Surname = _studentEntity.Surname, SwimEnglandNumber = _studentEntity.SwimEnglandNumber, CurrentGradeNumber = _studentEntity.CurrentGradeNumber, DateOfBirth = _studentEntity.DateOfBirth, MedicalDetails = _studentEntity.MedicalDetails }); }
private DataSet BonafideCertificate(int StudentId) { DataSet ds = new DataSet(); ds.DataSetName = "DataSourceForReport"; DataTable dt = new DataTable("BonafideCertificate"); dt.TableName = "BonafideCertificate"; dt.Columns.Add(new DataColumn("StudentId", typeof(int))); dt.Columns.Add(new DataColumn("StudentFullName", typeof(string))); dt.Columns.Add(new DataColumn("DateOfBirth", typeof(string))); dt.Columns.Add(new DataColumn("DateOfBirthInWord", typeof(string))); dt.Columns.Add(new DataColumn("Studying", typeof(string))); dt.Columns.Add(new DataColumn("Year", typeof(string))); dt.Columns.Add(new DataColumn("CastAndSubCast", typeof(string))); dt.Columns.Add(new DataColumn("ReserveCategory", typeof(string))); dt.Columns.Add(new DataColumn("RegisterNo", typeof(int))); int studentId = (int)PresentationLayer.Helpers.SessionHelper.StudentId; StudentBAL balObject = new StudentBAL(); //IQueryable<Entities.Student> entites = balObject.FindBy(s => s.StudentId == studentId ); IQueryable <Entities.Student> entites = balObject.GetAll(SessionHelper.SchoolId).Where(c => c.StudentId == studentId); if (entites != null && entites.Count() > 0) { Entities.Student entity = entites.FirstOrDefault(); DataRow dr = dt.NewRow(); dr["StudentId"] = studentId; dr["StudentFullName"] = string.Concat(entity.FirstName.Trim(), " ", entity.MiddleName.Trim(), " ", entity.LastName.Trim());; dr["CastAndSubCast"] = entity.ReligionName + " - " + entity.CastName; dr["DateOfBirth"] = entity.DateOfBirth.ToString("dd-MM-yyyy"); //Date if (entity.DateOfBirth != null) { dr["DateOfBirthInWord"] = DateToText(entity.DateOfBirth); } else { dr["DateOfBirthInWord"] = ""; } dr["Studying"] = entity.ClassName; //dr["Year"] = entity.AcademicYear; dr["ReserveCategory"] = entity.ReserveCategory; dr["RegisterNo"] = entity.RegisterId; dt.Rows.Add(dr); reportName = entity.RegisterId + "_" + entity.LastName.Trim() + "_" + entity.FirstName.Trim(); } ds.Tables.Add(getSchoolDetails()); ds.Tables.Add(dt); return(ds); }
// // GET: /SysAdmin/Student/Edit/5 public ActionResult Edit(int id) { StudentAddressVM viewModel = new StudentAddressVM(); CountryBAL countryBAL = new CountryBAL(); viewModel.Countries = from obj in countryBAL.GetAll().Where(c => c.Status == true) select new SelectListItem() { Text = obj.CountryName, Value = obj.CountryId.ToString() }; //Get Student Id StudentBAL balStudentObject = new StudentBAL(); IQueryable <Entities.Student> studentEntities = balStudentObject.FindBy(s => s.SrNo == id); if (studentEntities != null && studentEntities.Count() > 0) { Entities.Student studentEnity = studentEntities.FirstOrDefault(); viewModel.StudentId = studentEnity.StudentId; viewModel.StudentFullNameWithTitle = string.Concat(studentEnity.Title.Trim(), " ", studentEnity.FirstName.Trim(), " ", studentEnity.MiddleName.Trim(), " ", studentEnity.LastName).Trim(); viewModel.Status = true; } StudentAddressBAL balObject = new StudentAddressBAL(); IQueryable <Entities.StudentAddress> entites = balObject.GetAll(viewModel.StudentId); if (entites != null && entites.Count() > 0) { Entities.StudentAddress entity = entites.FirstOrDefault(); //viewModel.StudentId = entity.StudentId; //viewModel.StudentFullNameWithTitle = entity.StudentFullName; viewModel.CurrentAddress = entity.CurrentAddress; viewModel.CurrentCountryId = entity.CurrentCountryId; viewModel.CurrentStateId = entity.CurrentStateId; viewModel.CurrentDistrictId = entity.CurrentDistrictId; viewModel.CurrentCityId = entity.CurrentCityId; viewModel.PermentAddress = entity.PermentAddress; viewModel.PermentCountryId = entity.PermentCountryId; viewModel.PermentStateId = entity.PermentStateId; viewModel.PermentDistrictId = entity.PermentDistrictId; viewModel.PermentCityId = entity.PermentCityId; viewModel.CurrentPinCode = entity.CurrentPinCode; viewModel.PermentPinCode = entity.PermentPinCode; viewModel.Status = entity.Status; viewModel.Remark = entity.Remark; } //else //{ // viewModel.StudentId = id; // viewModel.StudentFullNameWithTitle = PresentationLayer.Other.CommanMethods.GetStudentName(id); // viewModel.Status = true; //} return(View(viewModel)); }
public IActionResult EnrollStudent(EnrollStudentReq request) { /* * var response = _dbService.EnrollStudent(request); * if (response.Error != null) * { * return BadRequest(response.Error); * } */ var idStudy = _studentContext.Studies.Where(s => s.Name == request.Studies).Select(s => s.IdStudy).FirstOrDefault(); if (idStudy == 0) // default { return(BadRequest("Study not found")); } var idEnrollment = _studentContext.Enrollment.Where(e => e.IdStudy == idStudy && e.Semester == 1).Select(e => e.IdEnrollment).FirstOrDefault(); if (idEnrollment == 0) // default { idEnrollment = _studentContext.Enrollment.Select(e => e.IdEnrollment).Max() + 1; var enrollment = new Entities.Enrollment { IdEnrollment = idEnrollment, IdStudy = idStudy, Semester = 1, StartDate = DateTime.Now }; _studentContext.Add(enrollment); } var student = new Entities.Student { IndexNumber = request.IndexNumber, FirstName = request.FirstName, LastName = request.LastName, Password = request.Password, RefreshToken = request.Password, BirthDate = request.BirthDate, IdEnrollment = idEnrollment, IdRole = request.IdRole, }; _studentContext.Add(student); _studentContext.SaveChanges(); var response = new { IdEnrollment = idEnrollment }; return(Ok(response)); }
public void SaveStudent(Entities.Student student) { if (student.id == 0) { context.Students.Add(student); } else { context.Entry(student).State = Microsoft.EntityFrameworkCore.EntityState.Modified; } context.SaveChanges(); }
public bool Insert(Entities.Student student) { try { context.Students.Add(student); return(true); } catch { return(false); } }
/// <summary> /// Get student full name with title by student id /// </summary> /// <param name="StudentId">Student id</param> /// <returns>Student name</returns> public static string GetStudentName(int StudentId) { string studentFullName = string.Empty; StudentBAL studentObject = new StudentBAL(); IQueryable <Entities.Student> students = studentObject.FindBy(s => s.StudentId == StudentId); if (students != null && students.Count() > 0) { Entities.Student student = students.FirstOrDefault(); studentFullName = string.Concat(student.Title.Trim(), " ", student.FirstName.Trim(), " ", student.MiddleName.Trim(), " ", student.LastName).Trim(); } return(studentFullName); }
public bool Ekle(Entities.Student model) { var result = false; try { this.dbContext.Students.Add(model); this.dbContext.SaveChanges(); result = true; } catch (Exception) { } return(result); }
public IActionResult delStudent(string index) { var zmiana = new Entities.Student(); zmiana.IndexNumber = index; _StudentContext.Student.Attach(zmiana); _StudentContext.Remove(zmiana); _StudentContext.SaveChanges(); return(Ok("deleted student")); }
public static StudentVM getStudentViewModel(Entities.Student entity) { StudentVM viewModel = new StudentVM(); viewModel.SrNo = entity.SrNo; viewModel.StudentId = entity.StudentId; viewModel.RegisterId = entity.RegisterId; viewModel.ClassDivisionId = entity.ClassDivisionId; viewModel.ClassId = entity.ClassId; viewModel.DivisionId = entity.DivisionId; viewModel.ClassName = entity.ClassName; viewModel.DivisionName = entity.DivisionName; viewModel.Title = entity.Title; viewModel.FirstName = entity.FirstName; viewModel.MiddleName = entity.MiddleName; viewModel.LastName = entity.LastName; viewModel.MotherName = entity.MotherName; viewModel.Gender = entity.Gender; viewModel.Nationality = entity.Nationality; viewModel.ReligionCastId = entity.ReligionCastId; viewModel.ReligionId = entity.ReligionId; viewModel.CastId = entity.CastId; viewModel.ReligionName = entity.ReligionName; viewModel.CastName = entity.CastName; viewModel.ReserveCategory = entity.ReserveCategory; viewModel.DateOfBirth = entity.DateOfBirth; viewModel.PlaceOfBirth = entity.PlaceOfBirth.Trim(); viewModel.AdharcardNo = entity.AdharcardNo; viewModel.DateOfAdmission = entity.DateOfAdmission; viewModel.LastSchoolAttended = entity.LastSchoolAttended; viewModel.Progress = entity.Progress; viewModel.Conduct = entity.Conduct; viewModel.DateOfLeavingSchool = entity.DateOfLeavingSchool; viewModel.ClassInWhichStudingAndSinceWhen = entity.ClassInWhichStudingAndSinceWhen; viewModel.ReasonForLeavingSchool = entity.ReasonForLeavingSchool; viewModel.RemarkOnTC = entity.RemarkOnTC; viewModel.Status = entity.Status; viewModel.Remark = entity.Remark; viewModel.PrevSchoolDateofLiving = entity.PrevSchoolDateofLiving; viewModel.StudentFullNameWithTitle = string.Concat(entity.Title.Trim(), " ", entity.FirstName.Trim(), " ", entity.MiddleName.Trim(), " ", entity.LastName.Trim()).Trim(); viewModel.ClassDivision = string.Concat(entity.ClassName.Trim(), "-", entity.DivisionName.Trim()).Trim(); viewModel.ReligionCast = string.Concat(entity.ReligionName.Trim(), "-", entity.CastName.Trim()).Trim(); viewModel.TCNo = entity.TCNo; viewModel.TCPrinted = entity.TCPrinted; viewModel.Balance = entity.Balance; viewModel.MobileNumber = entity.MobileNumber; return(viewModel); }
private DataSet BirthCertificate(int StudentId) { DataSet ds = new DataSet(); ds.DataSetName = "DataSourceForReport"; DataTable dt = new DataTable("BirthCertificate"); dt.TableName = "BirthCertificate"; dt.Columns.Add(new DataColumn("StudentId", typeof(int))); dt.Columns.Add(new DataColumn("RegisterNo", typeof(int))); dt.Columns.Add(new DataColumn("StudentFullName", typeof(string))); dt.Columns.Add(new DataColumn("PlaceOfBirth", typeof(string))); dt.Columns.Add(new DataColumn("DateOfBirth", typeof(DateTime))); dt.Columns.Add(new DataColumn("DateOfBirthInWord", typeof(string))); int studentId = (int)PresentationLayer.Helpers.SessionHelper.StudentId; StudentBAL balObject = new StudentBAL(); //IQueryable<Entities.Student> entites = balObject.FindBy(s => s.StudentId == studentId); IQueryable <Entities.Student> entites = balObject.GetAll(SessionHelper.SchoolId).Where(c => c.StudentId == studentId); if (entites != null && entites.Count() > 0) { Entities.Student entity = entites.FirstOrDefault(); DataRow dr = dt.NewRow(); dr["StudentId"] = studentId; dr["RegisterNo"] = entity.RegisterId; dr["StudentFullName"] = string.Concat(entity.FirstName.Trim(), " ", entity.MiddleName.Trim(), " ", entity.LastName.Trim()); dr["PlaceOfBirth"] = entity.PlaceOfBirth; dr["DateOfBirth"] = entity.DateOfBirth; //Date dr["DateOfBirthInWord"] = entity.DateOfBirth; if (entity.DateOfBirth != null) { dr["DateOfBirthInWord"] = DateToText(entity.DateOfBirth); } else { dr["DateOfBirthInWord"] = ""; } dt.Rows.Add(dr); reportName = entity.RegisterId + "_" + entity.LastName.Trim() + "_" + entity.FirstName.Trim(); } ds.Tables.Add(getSchoolDetails()); ds.Tables.Add(dt); return(ds); }
public static bool GetStudentTCStatus(int StudentId) { if (StudentId > 0) { string studentFullName = string.Empty; StudentBAL studentObject = new StudentBAL(); IQueryable <Entities.Student> students = studentObject.FindBy(s => s.StudentId == StudentId); if (students != null && students.Count() > 0) { Entities.Student student = students.FirstOrDefault(); return(student.TCPrinted); } } return(false); }
public bool Güncelle(int id, Entities.Student model) { var result = false; try { var data = this.dbContext.Students.Where(x => x.id == id).First(); data.name_surname = model.name_surname; data.number = model.number; data.classroom = model.classroom; this.dbContext.SaveChanges(); result = true; } catch (Exception) { } return(result); }
public ActionResult StudentLedger() { StudentLedgerBAL studentLedgerBAL = new StudentLedgerBAL(); IQueryable <Entities.StudentLedger> entities = studentLedgerBAL.GetAll(); FeeHeadBAL feeHeadBAL = new FeeHeadBAL(); IQueryable <Entities.FeeHead> feeHeads = feeHeadBAL.GetAll(); List <StudentLedgerVM> studentLedgerVMs = new List <StudentLedgerVM>(); foreach (Entities.StudentLedger entity in entities) { StudentLedgerVM studentLedgerVM = new StudentLedgerVM(); studentLedgerVM.StudentLedgerId = entity.StudentLedgerId; studentLedgerVM.StudentId = entity.StudentId; StudentBAL studentObject = new StudentBAL(); Entities.Student student = studentObject.FindBy(s => s.StudentId == entity.StudentId).FirstOrDefault(); if (student != null) { studentLedgerVM.StudentFullNameWithTitle = string.Concat(student.Title, " ", student.FirstName, " ", student.MiddleName, " ", student.LastName).Trim(); } studentLedgerVM.TransactionDate = entity.TransactionDate; studentLedgerVM.FeeHeadId = entity.FeeHeadId; studentLedgerVM.FeeHeadName = feeHeads.Where(fh => fh.FeeHeadId == entity.FeeHeadId).FirstOrDefault().FeeHeadName; studentLedgerVM.Cr = entity.Cr; studentLedgerVM.Dr = entity.Dr; studentLedgerVM.HeadBalance = entity.HeadBalance; studentLedgerVM.Balance = entity.Balance; studentLedgerVM.ReceiptNo = entity.ReceiptNo; studentLedgerVM.BankName = entity.BankName; studentLedgerVM.ChequeNumber = entity.ChequeNumber; studentLedgerVM.Status = entity.Status; studentLedgerVM.Remark = entity.Remark; //studentLedgerVM.CreatedBy = Convert.ToInt32(dr["CreatedBy"]); //studentLedgerVM.CreatedDate = Convert.ToDateTime(dr["CreatedDate"]); //studentLedgerVM.ModifiedBy = Convert.ToInt32(dr["ModifiedBy"]); //studentLedgerVM.ModifiedDate = Convert.ToDateTime(dr["ModifiedDate"]); studentLedgerVMs.Add(studentLedgerVM); } return(View(new GridModel <StudentLedgerVM> { Data = studentLedgerVMs })); }
public IActionResult updateStudentE(Entities.Student student) { var zmiana = new Entities.Student(); zmiana.IndexNumber = student.IndexNumber; _StudentContext.Student.Attach(zmiana); zmiana.IndexNumber = student.IndexNumber; zmiana.FirstName = student.FirstName; zmiana.LastName = student.LastName; zmiana.BirthDate = student.BirthDate; zmiana.IdEnrollment = student.IdEnrollment; _StudentContext.SaveChanges(); return(Ok(student)); }
public async Task <ActionResult <Models.CreateStudentResponse> > CreateStudent([FromBody] Models.Student _student) { Models.CreateStudentResponse response; if (User.Identity.IsAuthenticated) { var policyCheck = await authService.AuthorizeAsync(User, "AdminPolicy"); if (!policyCheck.Succeeded) { return(Unauthorized(response = new Models.CreateStudentResponse() { Success = false, Error = Models.ApiError.UnAuthResponse() })); } } Entities.Student newStudentEntity = Entities.Student.GetEntity(_student); if (!Entities.Student.CheckRequirements(newStudentEntity)) { return(BadRequest(response = new Models.CreateStudentResponse() { Success = false, Error = new Models.ApiError() { Message = "Cannot create this student", Detail = "This request is missing data", Code = (int)Models.ServerResponse.ErrorCodes.MISSING_DATA } })); } await studentDbContext.AddAsync(newStudentEntity); await studentDbContext.SaveChangesAsync(); response = new Models.CreateStudentResponse() { Success = true, Student = new Models.standard.Item <Models.Student>() { itemValue = Entities.Student.GetStudent(newStudentEntity) } }; return(Ok(response)); }
//public IActionResult CreateStudent(Models.Student student) public IActionResult CreateStudent(AddStudentReq student) { //int inserted = _dbService.InsertStudent(student); //return Ok($"Inserted students: {inserted}"); var studentEntity = new Entities.Student { IndexNumber = student.IndexNumber, FirstName = student.FirstName, LastName = student.LastName, BirthDate = student.BirthDate, IdEnrollment = student.IdEnrollment, IdRole = 1, Password = "******", Salt = "salt" }; _studentContext.Add(studentEntity); _studentContext.SaveChanges(); return(Ok($"Inserted")); }
public async Task <ActionResult <Models.ModifyStudentResponse> > ModifyStudent([FromBody] Models.Student _student) { Models.ModifyStudentResponse response; if (User.Identity.IsAuthenticated) { var policyCheck = await authService.AuthorizeAsync(User, "AdminPolicy"); if (!policyCheck.Succeeded) { return(Unauthorized(response = new Models.ModifyStudentResponse() { Success = false, Error = Models.ApiError.UnAuthResponse() })); } } Entities.Student entity = await studentDbContext.Students.FirstOrDefaultAsync <Entities.Student>(e => e.ID == _student.ID); if (entity == null) { return(BadRequest(response = new Models.ModifyStudentResponse() { Success = false, Error = new Models.ApiError() { Message = "Cannot modify this student", Detail = "This student does not exist", Code = (int)Models.ServerResponse.ErrorCodes.STUDENT_NOT_EXIST } })); } Entities.Student.ApplyChanges(_student, ref entity); await studentDbContext.SaveChangesAsync(); response = new Models.ModifyStudentResponse() { Success = true, Student = new Models.standard.Item <Models.Student>() { itemValue = Entities.Student.GetStudent(entity) } }; return(Ok(response)); }
public async Task <ActionResult <Models.DeleteStudentResponse> > DeleteStudent([FromBody] int _id) { Models.DeleteStudentResponse response; if (User.Identity.IsAuthenticated) { var policyCheck = await authService.AuthorizeAsync(User, "AdminPolicy"); if (!policyCheck.Succeeded) { return(Unauthorized(response = new Models.DeleteStudentResponse() { Success = false, Error = Models.ApiError.UnAuthResponse() })); } } Entities.Student entity = await studentDbContext.Students.FirstOrDefaultAsync <Entities.Student>(e => e.ID == _id); if (entity == null) { return(BadRequest(response = new Models.DeleteStudentResponse() { Success = false, Error = new Models.ApiError() { Message = "Cannot delete this student", Detail = "This student does not exist", Code = (int)Models.ServerResponse.ErrorCodes.STUDENT_NOT_EXIST } })); } studentDbContext.Remove(entity); await studentDbContext.SaveChangesAsync(); response = new Models.DeleteStudentResponse() { Success = true, ID = _id }; return(Ok(response)); }