コード例 #1
0
        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"));
        }
コード例 #2
0
        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());
        }
コード例 #3
0
        public async Task <bool> updateStudent(UpdateStudent student)
        {
            //Validar Existencia de Student
            await repository.updateStudent(student);

            await repository.SaveChangesAsync();

            return(true);
        }
コード例 #4
0
 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());
     }
 }
コード例 #5
0
        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());
        }
コード例 #6
0
 public static Student ToEntity(this UpdateStudent updateStudent)
 {
     return(new Student()
     {
         Id = updateStudent.Id
         ,
         Name = updateStudent.Name
         ,
         Grade = updateStudent.Grade
         ,
         School = updateStudent.School
     });
 }
コード例 #7
0
        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"));
        }
コード例 #8
0
        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));
        }
コード例 #9
0
        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;
        }
コード例 #10
0
        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);
        }
コード例 #11
0
        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());
        }
コード例 #12
0
        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));
        }
コード例 #13
0
ファイル: StudentsRepo.cs プロジェクト: coltandrews/quest-API
        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();
            }
        }
コード例 #14
0
        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);
            }
        }
コード例 #15
0
        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));
        }
コード例 #16
0
        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;
            }
        }
コード例 #17
0
        // 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);
        }
コード例 #18
0
        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));
        }
コード例 #19
0
        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);
        }
コード例 #20
0
 public void UpdateStudentFormFlag(int id, [FromBody] UpdateStudent updater)
 {
     _studentsRepo.UpdateStudentFormFlag(id, updater);
 }
コード例 #21
0
 public RegisteredStudent Update(UpdateStudent reg)
 {
     return(this._studentService.Update(reg));
 }