public async Task <IActionResult> UpdateStudent(IndexStudentsListVM obj) { try { if (obj.Students != null) { var Students = new UpdateStudent_Students() { Id = obj.Students.Id, ClassId = obj.Students.ClassId, GenderId = obj.Students.GenderId, RegistrationNo = obj.Students.RegistrationNo, FirstName = obj.Students.FirstName, LastName = obj.Students.LastName, FatherName = obj.Students.FatherName, MotherName = obj.Students.MotherName, IP300X200 = obj.Students.IP300X200, Year = obj.Students.Year, PresentAddress = obj.Students.PresentAddress, PermanentAddress = obj.Students.PermanentAddress, DOB = obj.Students.DOB, fleImage = obj.Students.fleImage, IsActive = obj.Students.IsActive, AddedBy = 0, AddedDate = DateTime.Now, ModifiedBy = 0, ModifiedDate = DateTime.Now, DataType = null }; var StudentPromotions = new UpdateStudent_StudentPromotions() { ClassId = obj.Students.ClassId, StudentId = obj.Students.Id, Year = obj.Students.Year, RollNo = obj.StudentPromotions.RollNo, IsActive = obj.Students.IsActive, AddedBy = 0, AddedDate = DateTime.Now, ModifiedBy = 0, ModifiedDate = DateTime.Now, DataType = null }; var model = new UpdateStudent() { WebRootPath = _he.WebRootPath, Students = Students, StudentPromotions = StudentPromotions }; await Task.Run(() => _studentsServ.UpdateStudent(model)); } } catch (Exception) { return(BadRequest()); } return(RedirectToAction("SearchByClass")); }
public IActionResult Edit(UpdateStudent studentModel) { if (ModelState.IsValid) { Student student = _studentRepository.GetStudent(studentModel.Id); student.Name = studentModel.Name; student.Gender = studentModel.Gender; student.DateOfBirth = studentModel.DateOfBirth; student.Nationality = studentModel.Nationality; student.Phone = studentModel.Phone; student.MaritalStatus = studentModel.MaritalStatus; student.AddmissionType = studentModel.AddmissionType; student.NextOfKinName = studentModel.NextOfKinName; student.NextOfKinEmail = studentModel.NextOfKinEmail; student.NextOfKinPhone = studentModel.NextOfKinPhone; student.NextOfKinDocumentUrl = studentModel.NextOfKinDocumentUrl; student.BVN = studentModel.BVN; if (studentModel.Photo != null) { if (studentModel.ExistingPhotoPath != null) { string filepath = Path.Combine(hostingEnvironment.WebRootPath, "images", studentModel.ExistingPhotoPath); System.IO.File.Delete(filepath); } student.Photo = ProcessUploadedFile(studentModel); } _studentRepository.UpdateStudent(student); return(RedirectToAction("index")); } return(View()); }
public async Task <bool> updateStudent(UpdateStudent student) { //Validar Existencia de Student await repository.updateStudent(student); await repository.SaveChangesAsync(); return(true); }
public RegisteredStudent Update(UpdateStudent updateRegistry) { using (SchoolDataContext schoolContext = new SchoolDataContext()) { var studentToUpdate = updateRegistry.ToEntity(); schoolContext.Students.Attach(studentToUpdate); //schoolContext.Entry(studentToUpdate).Property(x => x.Name).IsModified = true; schoolContext.Entry(studentToUpdate).State = System.Data.Entity.EntityState.Modified; schoolContext.SaveChanges(); return(studentToUpdate.toDTO()); } }
public async Task <IHttpActionResult> UpdateStudent(UpdateStudent student) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } unitOfWork.Students.Update(Mapper.Map <Student>(student)); await unitOfWork.Save(); return(Ok()); }
public static Student ToEntity(this UpdateStudent updateStudent) { return(new Student() { Id = updateStudent.Id , Name = updateStudent.Name , Grade = updateStudent.Grade , School = updateStudent.School }); }
public async Task <IActionResult> updateStudent([FromBody] UpdateStudent student) { if (ModelState.IsValid) { var result = await service.updateStudent(student); if (result) { return(Ok(Tuple.Create(result))); } } return(BadRequest("Algo salio mal en la peticion")); }
public IActionResult Edit(UpdateStudent model) { if (ModelState.IsValid) { if (studentRepository.UpdateStudent(model) > 0) { return(RedirectToAction("Index", "Student")); } ModelState.AddModelError("", "System error, please try again later!"); } var classEdit = new UpdateStudent(); return(View(classEdit)); }
public async Task updateStudent(UpdateStudent student) { var studentEntity = await PIDBContext.Users.SingleAsync(u => u.Id == student.Id); studentEntity.UpdateDate = DateTime.Now; studentEntity.UserName = student.UserName; studentEntity.Email = student.Email; studentEntity.Name = student.Name; studentEntity.LastName = student.LastName; studentEntity.Age = student.Age; studentEntity.Birthday = student.Birthday; studentEntity.School = student.School; studentEntity.Grade = student.Grade; studentEntity.Uid = student.Uid; }
public async Task <object> Put(UpdateStudent request) { var response = new BaseResponse(); Expression <Func <Student, bool> > keySelector = x => x.Id == request.Id; var entity = await _studentService.GetById(keySelector : keySelector); request.ToEntity(entity); var result = await _studentService.Update(entity); response.Success = true; response.Message = "Update student success"; response.StatusCode = (int)HttpStatusCode.OK; response.Results = result.ConvertTo <StudentDto>(); return(response); }
public int UpdateStudent(UpdateStudent model) { var students = GetStudent(model.StudentId); if (students == null) { return(-1); } students.StudentName = model.StudentName; students.BirthDay = model.Birthday; students.Email = model.Email; students.ClassId = model.ClassId; students.PhoneNumber = model.PhoneNumber; context.Update(students); return(context.SaveChanges()); }
public IActionResult Edit(int id) { var students = studentRepository.GetStudent(id); var editStudent = new UpdateStudent(); if (students != null) { editStudent.StudentId = students.StudentId; editStudent.StudentName = students.StudentName; editStudent.Birthday = students.BirthDay; editStudent.ClassId = students.ClassId; editStudent.PhoneNumber = students.PhoneNumber; editStudent.Email = students.Email; editStudent.Classes = studentRepository.GetClasses(); } return(View(editStudent)); }
public void UpdateStudentFormFlag(int id, UpdateStudent updater) { using (SqlConnection connection = _database.GetConnection()) { SqlCommand cmd = new SqlCommand("UPDATE LiabilityForm SET SUBMITTED = @submitted WHERE STUDENT_ID = @id"); cmd.Parameters.AddWithValue("submitted", updater.Submitted); cmd.Parameters.AddWithValue("id", id); connection.Open(); cmd.Connection = connection; var recordsUpdated = cmd.ExecuteNonQuery(); connection.Close(); } }
public ActionResult <Student> Put(int id, [FromBody] UpdateStudent updateStudent) { var student = DbContext.Students.FirstOrDefault(s => s.ID == id); if (student == null) { return(NotFound("Sorry, no student was found with that ID.")); } else { student.FirstName = updateStudent.FirstName; student.LastName = updateStudent.LastName; student.EmailAddress = updateStudent.EmailAddress; student.LastUpdatedOn = DateTime.Now; DbContext.SaveChanges(); return(student); } }
public IActionResult EditStudent(UpdateStudent model) { var createResult = _StudentRepository.UpdateStudent(model); if (ModelState.IsValid) { if (createResult > 0) { return(RedirectToAction("StudentsList")); } else { TempData["Error"] = "Something went wrong, please try again later"; } } ViewBag.Language = GetLanguageList(); ViewBag.Level = GetAllLevel(); return(View(model)); }
public int UpdateStudent(UpdateStudent model) { int rowAffected = 0; try { DynamicParameters parameters = new DynamicParameters(); parameters.Add("@Id", model.Id); parameters.Add("@LanguageId", model.LanguageId); parameters.Add("@LevelId", model.LevelId); parameters.Add("@Name", model.Name); parameters.Add("@DayOfBirth", model.DayOfBirth); parameters.Add("@Sex", model.Sex); parameters.Add("@Email", model.Email); rowAffected = SqlMapper.Execute(con, "sp_UpdateStudent", param: parameters, commandType: CommandType.StoredProcedure); return(rowAffected); } catch (Exception ex) { throw ex; } }
// This method will be called for each input received from the pipeline to this cmdlet; if no input is received, this method is not called protected override void ProcessRecord() { UpdateStudent student = GetInitUpdateStudent(); // Populate from student object if object was used. if (_permissionToPhotographProvided) { student.PermissionToPhotograph = PermissionToPhotograph; } ; if (_usiIdProvided) { student.UsiId = UsiId; } if (_barcodeProvided) { student.Barcode = Barcode; } if (_examNumberProvided) { student.ExamNumber = ExamNumber; } if (_studentCodeProvided) { student.StudentCode = StudentCode; } if (_systemStudentIdProvided) { student.SystemStudentId = SystemStudentId; } if (_acaraIdProvided) { student.AcaraId = AcaraId; } var response = SentralApiClient.Enrolments.UpdateStudent(student); WriteObject(response); }
public ViewResult Edit(Guid Id) { Student student = _studentRepository.GetStudent(Id); UpdateStudent update = new UpdateStudent { Id = student.Id, Name = student.Name, Gender = student.Gender, DateOfBirth = student.DateOfBirth, Address = student.Address, Nationality = student.Nationality, Phone = student.Phone, ExistingPhotoPath = student.Photo, MaritalStatus = student.MaritalStatus, AddmissionType = student.AddmissionType, NextOfKinName = student.NextOfKinName, NextOfKinEmail = student.NextOfKinEmail, NextOfKinPhone = student.NextOfKinPhone, NextOfKinDocumentUrl = student.NextOfKinDocumentUrl, BVN = student.BVN }; return(View(update)); }
public string UpdateStudent(UpdateStudent obj) { string returnResult = (dynamic)null; try { if (obj != null) { var AdmittedYear = DateTime.ParseExact(obj.Students.Year, "yyyy", null); if (obj.Students != null) { var currentItem = _studentsRepo.Get(obj.Students.Id); currentItem.ClassId = obj.Students.ClassId; currentItem.GenderId = obj.Students.GenderId; currentItem.RegistrationNo = obj.Students.RegistrationNo; currentItem.FirstName = obj.Students.FirstName; currentItem.LastName = obj.Students.LastName; currentItem.AdmittedYear = AdmittedYear; currentItem.PresentAddress = obj.Students.PresentAddress; currentItem.PermanentAddress = obj.Students.PermanentAddress; currentItem.DOB = obj.Students.DOB; currentItem.IsActive = obj.Students.IsActive; currentItem.ModifiedBy = 0; currentItem.ModifiedDate = DateTime.Now; currentItem.FatherName = obj.Students.FatherName; currentItem.MotherName = obj.Students.MotherName; if (obj.Students.fleImage == null) { if (obj.Students.IP300X200 != null) { currentItem.IP300X200 = obj.Students.IP300X200; } else { //[NOTE: delete image from 'ClientDictionary'] string targetImageLocation = Path.Combine(obj.WebRootPath, currentItem.IP300X200); _commonServ.DelFileFromLocation(targetImageLocation); } } else { //[NOTE: delete image from 'ClientDictionary-if extensions are different'] if (currentItem.IP300X200 != null) { string targetImageLocation = Path.Combine(obj.WebRootPath, currentItem.IP300X200); _commonServ.DelFileFromLocation(targetImageLocation); } //[NOTE: Upddate image] string imagePathIP300X200 = "ClientDictionary/Students/IP300X200/"; string extension = Path.GetExtension(obj.Students.fleImage.FileName); if (_commonServ.CommImage_ImageFormat(obj.Students.Id.ToString(), obj.Students.fleImage, obj.WebRootPath, imagePathIP300X200, 200, 300, extension).Equals(true)) { currentItem.IP300X200 = imagePathIP300X200 + obj.Students.Id + extension; } } _studentsRepo.Update(currentItem); returnResult = "Saved"; } //[NOTE: Student promotion table table] if (obj.StudentPromotions != null) { var promotion = _StudentPromotionsRepo.GetAll().ToList(); var getStuPromotion = (from sp in promotion where sp.StudentId == obj.Students.Id select sp).FirstOrDefault(); getStuPromotion.ClassId = obj.Students.ClassId; getStuPromotion.RollNo = obj.StudentPromotions.RollNo; getStuPromotion.ClassYear = AdmittedYear; getStuPromotion.IsActive = obj.Students.IsActive; getStuPromotion.ModifiedBy = 0; getStuPromotion.ModifiedDate = DateTime.Now; _StudentPromotionsRepo.Update(getStuPromotion); returnResult = "Saved"; } } } catch (Exception ex) { returnResult = "ERROR102:AddressesServ/UpdateAddress - " + ex.Message; } return(returnResult); }
public void UpdateStudentFormFlag(int id, [FromBody] UpdateStudent updater) { _studentsRepo.UpdateStudentFormFlag(id, updater); }
public RegisteredStudent Update(UpdateStudent reg) { return(this._studentService.Update(reg)); }