public async Task <Student> Get(long Id) { Student student = await context.Student.Where(s => s.Id == Id).Select(s => new Student { Id = s.Id, Address = s.Address, Dob = s.Dob, Email = s.Email, Gender = s.Gender, EthnicId = s.EthnicId, EthnicCode = s.Ethnic.Code, EthnicName = s.Ethnic.Name, HighSchoolId = s.HighSchoolId, HighSchoolCode = s.HighSchool.Code, HighSchoolName = s.HighSchool.Name, Name = s.Name, Phone = s.Phone, PlaceOfBirth = s.PlaceOfBirth, TownId = s.TownId, TownCode = s.Town.Code, TownName = s.Town.Name, DistrictId = s.Town.DistrictId, DistrictCode = s.Town.District.Code, DistrictName = s.Town.District.Name, ProvinceId = s.Town.District.ProvinceId, ProvinceCode = s.Town.District.Province.Code, ProvinceName = s.Town.District.Province.Name, Identify = s.Identify, Image = s.Image, Biology = s.Biology, Chemistry = s.Chemistry, CivicEducation = s.CivicEducation, Geography = s.Geography, History = s.History, Languages = s.Languages, Literature = s.Literature, Maths = s.Maths, Physics = s.Physics, Status = s.Status }).FirstOrDefaultAsync(); RegisterExamDAO formDAO = context.RegisterExam.Where(f => f.StudentId == Id).FirstOrDefault(); if (formDAO != null && formDAO.Graduated.HasValue) { student.Graduated = formDAO.Graduated.Value; } return(student); }
public async Task <bool> Create(RegisterExam form) { RegisterExamDAO formDAO = new RegisterExamDAO { Id = form.Id, Graduated = form.Graduated, ClusterContestId = form.ClusterContestId, RegisterPlaceOfExamId = form.RegisterPlaceOfExamId, Maths = form.Maths, Literature = form.Literature, Languages = form.Languages, NaturalSciences = form.NaturalSciences, SocialSciences = form.SocialSciences, Physics = form.Physics, Chemistry = form.Chemistry, Biology = form.Biology, History = form.History, Geography = form.Geography, CivicEducation = form.CivicEducation, ExceptLanguages = form.ExceptLanguages, Mark = form.Mark, ReserveMaths = form.ReserveMaths, ReserveLiterature = form.ReserveLiterature, ReserveLanguages = form.ReserveLanguages, ReservePhysics = form.ReservePhysics, ReserveChemistry = form.ReserveChemistry, ReserveBiology = form.ReserveBiology, ReserveHistory = form.ReserveHistory, ReserveGeography = form.ReserveGeography, ReserveCivicEducation = form.ReserveCivicEducation, PriorityType = form.PriorityType, Area = form.Area, Status = form.Status, StudentId = CurrentContext.StudentId, }; context.RegisterExam.Add(formDAO); if (form.Aspirations.Any()) { await BulkCreateAspirations(form); } await context.SaveChangesAsync(); return(true); }