Exemple #1
0
        public ActionResult GovernmentApprovedId(GovernMentApprovedIdViewModel governmentApprovedModel)
        {
            try
            {
                JsonResult jsonData = null;

                if (ModelState.IsValid)
                {
                    var existingUser = UserManager.FindById(User.Identity.GetUserId <long>());
                    if (existingUser != null)
                    {
                        if (governmentApprovedModel.IdImagePostedFile != null && IsValideImage(governmentApprovedModel.IdImagePostedFile))
                        {
                            if (!string.IsNullOrEmpty(existingUser.GovApprovedPhotoIdUrl))
                            {
                                string photoUrl = existingUser.GovApprovedPhotoIdUrl;

                                var uniqueFileName = photoUrl.Substring(photoUrl.LastIndexOf('/') + 1);

                                clsUtils.DeleteAzureUploadedFile(PropertyConstant.CustomerProfileImages, uniqueFileName);
                            }
                            using (MemoryStream target = new MemoryStream())
                            {
                                governmentApprovedModel.IdImagePostedFile.InputStream.CopyTo(target);
                                byte[] data = target.ToArray();

                                var uniqueFileName = Guid.NewGuid().ToString() + Path.GetExtension(governmentApprovedModel.IdImagePostedFile.FileName);

                                var currentUploadedFileUrl = clsUtils.fnUploadFileINBlobStorage(PropertyConstant.CustomerProfileImages, uniqueFileName, data, generateThumbnail: false);

                                existingUser.GovApprovedPhotoIdUrl = PropertyConstant.CustomerProfileImages + "/" + uniqueFileName;
                            }
                        }
                        existingUser.ID_Number = governmentApprovedModel.ID_Number;
                        existingUser.ID_Type   = governmentApprovedModel.ID_Type.ToString();
                        if (governmentApprovedModel.ExpirationDate != null)
                        {
                            existingUser.ExpirationDate = DateTime.Parse(governmentApprovedModel.ExpirationDate);
                        }
                        UserManager.Update(existingUser);
                    }
                    jsonData = Json(new { status = true, message = " Government Approved Details updated successfully ! " });
                }
                else
                {
                    jsonData = Json(new { status = false, message = GetErrorsFromModelState(ModelState.Values.ToList()) });
                }

                return(jsonData);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #2
0
        public ActionResult GovernmentApprovedId()
        {
            var existingUser         = UserManager.FindById(User.Identity.GetUserId <long>());
            var govApprovedViewModel = new GovernMentApprovedIdViewModel();

            govApprovedViewModel.ID_Number        = existingUser.ID_Number;
            govApprovedViewModel.UploadedPhotoUrl = ConfigurationManager.AppSettings["BlobUrl"] + existingUser.GovApprovedPhotoIdUrl;
            if (!string.IsNullOrEmpty(existingUser.ID_Type))
            {
                govApprovedViewModel.ID_Type = (Id_Type)Enum.Parse(typeof(Id_Type), existingUser.ID_Type, true);
            }
            govApprovedViewModel.ExpirationDate = existingUser.ExpirationDate.ToShortDateString();
            return(PartialView("_GovernmentApprovedId", govApprovedViewModel));
        }