public string InsertStudentPromotions(InsertStudentPromotions obj) { string returnResult = (dynamic)null; try { if (obj != null) { var ClassYear = DateTime.ParseExact(obj.StudentPromotions.Year, "yyyy", null); //[Note: insert 'states' table] if (obj.StudentPromotions != null) { var StudentPromotions = new InsertStudentPromotions_StudentPromotions() { StudentId = obj.StudentPromotions.StudentId, ClassId = obj.StudentPromotions.ClassId, RollNo = obj.StudentPromotions.RollNo, ClassYear = ClassYear, IsActive = obj.StudentPromotions.IsActive, AddedBy = 0, AddedDate = DateTime.Now, ModifiedBy = 0, ModifiedDate = DateTime.Now, DataType = null }; _StudentPromotionsRepo.Insert(StudentPromotions); returnResult = "Saved"; } } } catch (Exception ex) { returnResult = "ERROR102:PromotionClassesServ/InsertPromotionList - " + ex.Message; } return(returnResult); }
public string InsertStudent(InsertStudent obj) { string returnResult = (dynamic)null; try { var studentsList = _studentsRepo.GetAll().ToList(); var getregistration = (from stu in studentsList where stu.RegistrationNo == obj.Students.RegistrationNo select stu).SingleOrDefault(); //var Studentlist = _studentsRepo.Get(obj.Students.Id); //var query=(from stu) if (getregistration == null) { if (obj != null) { var AdmittedYear = DateTime.ParseExact(obj.Students.Year, "yyyy", null); //[Note: insert 'states' table] if (obj.Students != null) { var Students = new InsertStudent_Students() { ClassId = obj.Students.ClassId, GenderId = obj.Students.GenderId, RegistrationNo = obj.Students.RegistrationNo, FirstName = obj.Students.FirstName, LastName = obj.Students.LastName, IP300X200 = obj.Students.IP300X200, AdmittedYear = AdmittedYear, PresentAddress = obj.Students.PresentAddress, PermanentAddress = obj.Students.PermanentAddress, DOB = obj.Students.DOB, IsActive = obj.Students.IsActive, AddedBy = obj.Students.AddedBy = 0, AddedDate = DateTime.Now, ModifiedBy = 0, ModifiedDate = DateTime.Now, FatherName = obj.Students.FatherName, MotherName = obj.Students.MotherName, DataType = null }; //[NOTE: Student table] _studentsRepo.Insert(Students); if (obj.Students.fleImage != null) { string imagePathIP300X200 = "ClientDictionary/Students/IP300X200/"; string extension = Path.GetExtension(obj.Students.fleImage.FileName); var lastAddingRecord = _studentsRepo.GetAll().Last(); if (_commonServ.CommImage_ImageFormat(lastAddingRecord.Id.ToString(), obj.Students.fleImage, obj.WebRootPath, imagePathIP300X200, 200, 300, extension).Equals(true)) { //[NOTE:Update image file] var imgStudent = _studentsRepo.Get(lastAddingRecord.Id); imgStudent.IP300X200 = imagePathIP300X200 + lastAddingRecord.Id + extension; _studentsRepo.Update(imgStudent); } } } Int64 getLastId = _studentsRepo.GetLastId(); //[NOTE: Student promotion table table] if (obj.StudentPromotions != null) { var StudentPromotions = new InsertStudent_StudentPromotions() { StudentId = getLastId, ClassId = obj.Students.ClassId, RollNo = obj.StudentPromotions.RollNo, ClassYear = AdmittedYear, IsActive = obj.Students.IsActive, AddedBy = 0, AddedDate = DateTime.Now, ModifiedBy = 0, ModifiedDate = DateTime.Now, DataType = null }; _StudentPromotionsRepo.Insert(StudentPromotions); } } returnResult = "Saved"; } else { returnResult = "this registration number already exist"; } } catch (Exception ex) { returnResult = "ERROR102:Insert all required Info - " + ex.Message; } return(returnResult); }