public PassportViewModel GetPassportViewModel(int clientId)
 {
     PassportData passportData = this.clientProfileService.GetClientPassportData(clientId);
     var model = new PassportViewModel
                     {
                         ClientId = clientId,
                         ExpirationDate = passportData.ExpirationDate,
                         IssueDate = passportData.IssueDate,
                         Issuer = passportData.Issuer,
                         PassportNumber = passportData.PassportNumber,
                         PersonalNumber = passportData.PersonalNumber,
                     };
     if ((passportData.DigitalCopy == null) || (passportData.DigitalCopy.Length == 0)) model.HasImage = false;
     else model.HasImage = true;
     return model;
 }
 public void SavePassportData(PassportViewModel model, HttpPostedFileBase digitalCopy)
 {
     PassportData passportData = this.clientProfileService.GetClientPassportData(model.ClientId);
     passportData.ExpirationDate = model.ExpirationDate ?? DateTime.MinValue;
     passportData.IssueDate = model.IssueDate ?? DateTime.MinValue;
     passportData.Issuer = model.Issuer;
     passportData.PassportNumber = model.PassportNumber;
     passportData.PersonalNumber = model.PersonalNumber;
     if (digitalCopy != null)
         passportData.DigitalCopy = digitalCopy.ToByteArray();
     this.clientProfileService.Save(passportData);
 }
        public ActionResult Passport(PassportViewModel model)
        {
            if (!this.ModelState.IsValid)
            {
                return this.View(model);
            }

            var allowImageMimeTypes = new List<string>
                                                   {
                                                       "image/gif",
                                                       "image/jpeg",
                                                       "image/pjpeg",
                                                       "image/png",
                                                       "image/svg+xml",
                                                       "image/tiff",
                                                       "image/vnd.microsoft.icon",
                                                       "image/vnd.wap.wbmp"
                                                   };

            if ((model.File != null)&&(!allowImageMimeTypes.Contains(model.File.ContentType)))
            {
                ModelState.AddModelError("", "Unknown File Type!");
                return this.View(model);
            }

            model.ClientId = this.ResolveClientId(model.ClientId);
            this.clientProfileManager.SavePassportData(model, model.File);
            return this.RedirectToAction("Contacts");
        }