Ejemplo n.º 1
0
 private TrainerDocument GetTrainerDocument()
 {
     var trainerDocument = new TrainerDocument();
     trainerDocument.TrainerId = Context.Current.UserId;
     trainerDocument.CreatedOn = DateTime.Today;
     return trainerDocument;
 }
Ejemplo n.º 2
0
        internal void SaveDocuments(IEnumerable<TrainerDocument> TrainerDocument, IEnumerable<HttpPostedFileBase> UserEducation, IEnumerable<HttpPostedFileBase> UserEmployment, TrainerKYCModel model, HttpPostedFileBase TrainerIdentity)
        {
            try
            {
                ValidateUserDocuments(UserEducation);

                ValidateUserDocuments(UserEmployment);

                ValidateUserDocuments(new[] { TrainerIdentity });

                if (!string.IsNullOrEmpty(ErrorMessage)) return;

                List<TrainerDocument> documentsArray = new List<TrainerDocument>();

                int counter = 0;
                if (UserEducation != null)
                {
                    for (int i = 0; i < UserEducation.Count(); i++)
                    {
                        TrainerDocument trainerModel = GetTrainerDocument();
                        trainerModel.Id = TrainerDocument.ElementAt(counter).Id;
                        trainerModel.Location = SaveFile(UserEducation.ElementAt(i)) ?? TrainerDocument.ElementAt(counter).Location;
                        trainerModel.EducationId = TrainerDocument.ElementAt(counter).EducationId;
                        documentsArray.Add(trainerModel);
                        counter++;
                    }
                }
                if (UserEmployment != null)
                {
                    for (int i = 0; i < UserEmployment.Count(); i++)
                    {
                        TrainerDocument trainerModel = GetTrainerDocument();
                        trainerModel.Id = TrainerDocument.ElementAt(counter).Id;
                        trainerModel.Location = SaveFile(UserEmployment.ElementAt(i)) ?? TrainerDocument.ElementAt(counter).Location;
                        trainerModel.EmploymentId = TrainerDocument.ElementAt(counter).EmploymentId;
                        documentsArray.Add(trainerModel);
                        counter++;
                    }
                }

                var identityTrainerModel = GetTrainerDocument();
                identityTrainerModel.Id = model.TrainerDocument.Id;
                identityTrainerModel.Location = SaveFile(TrainerIdentity) ?? model.TrainerDocument.Location;
                identityTrainerModel.IdentityId = model.TrainerDocument.IdentityId;
                documentsArray.Add(identityTrainerModel);

                SaveTrainerDocuments(documentsArray);
            }
            catch (Exception exception)
            {
                ErrorMessage = exception.Message;
            }
        }