private string GetUserPhotoId(int portalId, string importFileId, ExportUser user)
        {
            int profilePictureId;

            if (string.IsNullOrEmpty(importFileId) ||
                !int.TryParse(importFileId, out profilePictureId))
            {
                return(null);
            }

            var files =
                FolderManager.Instance.GetFiles(
                    FolderManager.Instance.GetUserFolder(
                        UserController.GetUserByName(portalId, user.Username)))
                .ToList();

            if (!files.Any())
            {
                return(null);
            }

            var importUserFolder =
                this.Repository.GetItem <ExportFolder>(x => x.UserId == user.UserId);

            if (importUserFolder == null)
            {
                return(null);
            }

            {
                var profilePicture =
                    this.Repository.GetRelatedItems <ExportFile>(importUserFolder.Id)
                    .FirstOrDefault(x => x.FileId == profilePictureId);
                if (profilePicture != null &&
                    files.Any(x => x.FileName == profilePicture.FileName))
                {
                    return(Convert.ToString(
                               files.First(
                                   x => x.FileName == profilePicture.FileName)
                               .FileId));
                }
            }

            return(null);
        }
Exemple #2
0
        private void MBtnExportUser_Click(object sender, EventArgs e)
        {
            if (!rqExportData.IsValid)
            {
                rqExportData.ControlToValidate.Focus();

                return;
            }

            try
            {
                Path = mTxtExportPath.Text;
                ExportUser?.Invoke(this, null);
                mTxtExportPath.Text = "";
            }
            catch (Exception ex)
            {
                MessageBox.Show("Có lỗi khi xuất dữ liệu: " + ex.Message);
            }
        }
Exemple #3
0
        private void btnUserExport_Click(object sender, EventArgs e)
        {
            ExportUser eu = new ExportUser();

            eu.Show();
        }
Exemple #4
0
        public JsonResult GetUser(string userName)
        {
            var             user            = new ExportUser();
            string          gettingUserName = "";
            ServiceRibbon   serviceRibbon   = new ServiceRibbon();
            ApplicationUser applicationUser = new ApplicationUser();

            using (var context = new DatabaseContext())
            {
                context.ApplicationUsers.ForEach(x =>
                {
                    if (x.UserName == userName)
                    {
                        gettingUserName = x.UserNameToGet;
                    }
                });
                gettingUserName = "******";
                context.ApplicationUsers.ForEach(x =>
                {
                    if (x.UserName == gettingUserName)
                    {
                        applicationUser = x;
                    }
                });
                bool medal1 = false;
                bool medal2 = false;
                bool medal3 = false;
                bool medal4 = false;
                bool medal5 = false;
                context.ServiceRibbons.ToList().ForEach(sr =>
                {
                    if (sr.Id == applicationUser.MedalsList)
                    {
                        serviceRibbon = sr;
                    }
                });
                context.MedalsCommentator.ToList().ForEach(mc =>
                {
                    if (mc.Id == serviceRibbon.MedalCommentator)
                    {
                        medal1 = mc.IsReceived;
                    }
                });
                context.MedalsCritic.ToList().ForEach(mc =>
                {
                    if (mc.Id == serviceRibbon.MedalCritic)
                    {
                        medal2 = mc.IsReceived;
                    }
                });
                context.MedalsLiker.ToList().ForEach(mc =>
                {
                    if (mc.Id == serviceRibbon.MedalLiker)
                    {
                        medal3 = mc.IsReceived;
                    }
                });
                context.MedalsReader.ToList().ForEach(mc =>
                {
                    if (mc.Id == serviceRibbon.MedalReader)
                    {
                        medal4 = mc.IsReceived;
                    }
                });
                context.MedalsWriter.ToList().ForEach(mc =>
                {
                    if (mc.Id == serviceRibbon.MedalWriter)
                    {
                        medal5 = mc.IsReceived;
                    }
                });
                user = new ExportUser {
                    Id = applicationUser.Id, Email = applicationUser.Email, Medal1 = medal1, Medal2 = medal2, Medal3 = medal3, Medal4 = medal4, Medal5 = medal5
                };
            }
            return(Json(user, JsonRequestBehavior.AllowGet));
        }