Esempio n. 1
0
            public async Task <string> Handle(UpdateAppProfileToStudentCommand cmd, CancellationToken cancellationToken)
            {
                var init = await _mediator.Send(new GetAppProfileByProfileIdQuery(cmd.ProfileId));

                var mapper = new Mapper(_mapperConfiguration);

                Model.Profile profile = mapper.Map <Model.Profile>(init);

                if (profile.Handle(cmd))
                {
                    var dao = mapper.Map <ProfileDAO>(profile);

                    try
                    {
                        var filter = Builders <ProfileDAO> .Filter.Eq(x => x.Id, dao.Id);

                        var options = new FindOneAndReplaceOptions <ProfileDAO> {
                            ReturnDocument = ReturnDocument.After
                        };

                        var update = await _db.Profile.FindOneAndReplaceAsync(filter, dao, options);

                        return(update.Id.ToString());
                    }
                    catch (Exception)
                    {
                        return(string.Empty);
                    }
                }

                return(string.Empty);
            }
        public async Task OnGetAsync()
        {
            var mapper = new Mapper(_mapperConfiguration);

            Model.Profile profile = JsonSerializer.Deserialize <Model.Profile>(HttpContext.Session.GetString(HASSessionKeys.SessionKeyProfileName), DefaultJsonSettings.Settings);

            var media = await _mediator.Send(new ObtainAllSubscribedMediaQuery(profile.Id));

            Data = mapper.Map <IEnumerable <Thumbnail> >(media);
        }
Esempio n. 3
0
 internal Model.Profile.ProfileExtensionDefnComponent getExtensionDefinition(Model.Profile profile, string url)
 {
     if (url.StartsWith("#"))
     {
         var extAnchor = url.Substring(1);
         return(profile.ExtensionDefn.Where(ext => ext.Code == extAnchor).FirstOrDefault());
     }
     else
     {
         return(_loader.LocateExtension(new Uri(url)));
     }
 }
Esempio n. 4
0
 internal string getLinkForProfile(Model.Profile profile, string p)
 {
     return("todo.html" + "|" + profile.Name);
     //        String fn;
     //if (!url.startsWith("#")) {
     //  String[] path = url.split("#");
     //  profile = definitions.getProfileByURL(path[0]);
     //  if (profile == null && url.startsWith("Profile/"))
     //    return "hspc-"+url.substring(8)+".html|"+url.substring(8);
     //}
     //if (profile != null) {
     //  fn = profile.getTag("filename")+"|"+profile.getNameSimple();
     //  return Utilities.changeFileExt(fn, ".html");
     //}
     //return null;
 }
Esempio n. 5
0
        internal string getLinkForExtension(Model.Profile profile, string url)
        {
            return("todo.html");
            //String fn;
            //String code;
            //if (url.StartsWith("#"))
            //{
            //    code = url.Substring(1);
            //}
            //else
            //{
            //    String[] path = url.Split("#");
            //    code = path[1];
            //    profile = definitions.getProfileByURL(path[0]);
            //}

            //if (profile != null)
            //{
            //    fn = (String)profile.getTag("filename");
            //    return Utilities.changeFileExt(fn, ".html");
            //}
            //return null;
        }
Esempio n. 6
0
 internal ProfileViewModel(Model.Profile profile)
 {
     this.Id   = profile.Id;
     this.Name = profile.Name;
 }
 public void OnGet()
 {
     Model.Profile profile = JsonSerializer.Deserialize <Model.Profile>(HttpContext.Session.GetString(HASSessionKeys.SessionKeyProfileName), DefaultJsonSettings.Settings);
     StudentName = profile.PersonalDetails.FirstName;
 }
        public bool InsertProfile(int userID, ref string notificatedMessage)
        {
            int id = Libs.LibConvert.ConvertToInt(Request.QueryString["id"], 0);
            WebPortal.Model.Profile profile = new Model.Profile();
            profile.UserID = userID;
            if (!string.IsNullOrWhiteSpace(Request.Form["firstname"].ToString()))
            {
                profile.FirstName = Request.Form["firstname"].ToString();
            }

            if (!string.IsNullOrWhiteSpace(Request.Form["lastname"].ToString()))
            {
                profile.LastName = Request.Form["lastname"].ToString();
            }
            profile.Position = Request.Form["position"].ToString();

            if (Request.Files[0] != null)
            {
                HttpPostedFile file = Request.Files[0];
                if (file.ContentLength != 0)
                {
                    string fileName = string.Empty;
                    string path = "~/Resources/Images/";
                    if (!Libs.LibUpload.UploadFile(file, path, ref notificatedMessage, ref fileName, "jpg,jpeg,png,gif", 50000))
                    {
                        return false;
                    }
                    profile.Image = "/Resources/Images/" + fileName;
                }
            }

            profile.Address = Request.Form["address"].ToString();
            profile.Phone = Request.Form["phone"].ToString();
            profile.Birdthday = Libs.LibConvert.ConvertToDateTime(Request.Form["birthday"].ToString(), DateTime.Now);
            if (!string.IsNullOrWhiteSpace(Request.Form["genre"]))
            {
                if (Request.Form["genre"].ToString() == "male")
                {
                    profile.Genre = "Nam";
                }
                else
                {
                    profile.Genre = "Nữ";
                }
            }
            else
            {
                profile.Genre = "Nam";
            }

            profile.Ethnic = Request.Form["ethnic"].ToString();
            profile.Religion = Request.Form["religion"].ToString();
            profile.Active = true;
            if (profileRepository.Add(profile) != 0)
            {
                notificatedMessage = "Thêm profile thành công";
                return true;
            }
            else
            {
                notificatedMessage = "Thêm profile không thành công";
                return false;
            }
        }