コード例 #1
0
        // GET: Address
        public ActionResult Index()
        {
            int id = int.Parse(Session["user_id"].ToString());

            Models.Profile theProfile = database.Profiles.SingleOrDefault(p => p.user_id == id);
            return(View(theProfile));
        }
コード例 #2
0
        public ActionResult Index()
        {
            int id = Int32.Parse(Session["person_id"].ToString());

            Models.Profile theClient = db.Profiles.SingleOrDefault(c => c.person_id == id);
            return(View(theClient));
        }
コード例 #3
0
        public ActionResult Create(FormCollection collection)
        {
            try
            {
                // TODO: Add insert logic here
                int            id        = Int32.Parse(Session["user_id"].ToString());
                Models.Profile newClient = new Models.Profile();
                Models.User    theUser   = db.Users.SingleOrDefault(p => p.user_id == id);

                newClient.first_name   = collection["first_name"];
                newClient.last_name    = collection["last_name"];
                newClient.notes        = collection["notes"];
                newClient.gender       = collection["gender"];
                newClient.profile_pic  = "default.jpg";
                newClient.privacy_flag = "Off";


                db.Profiles.Add(newClient);
                theUser.person_id = newClient.person_id;

                db.SaveChanges();

                Models.Profile theProf = db.Profiles.SingleOrDefault(p => p.person_id == theUser.person_id);

                Session["person_id"] = theProf.person_id;

                return(View("Index", newClient));
            }
            catch
            {
                return(View());
            }
        }
コード例 #4
0
        public ActionResult Edit(int id, FormCollection collection, HttpPostedFileBase thePicture)
        {
            try
            {
                var type = thePicture.ContentType;

                string[] acceptableTypes = { "image/jpeg", "image/gif", "image/png" };

                if (thePicture != null && thePicture.ContentLength > 0 && acceptableTypes.Contains(type))
                {
                    Guid   g        = Guid.NewGuid();
                    String filename = g.ToString() + Path.GetExtension(thePicture.FileName);
                    String path     = Path.Combine(Server.MapPath("~/Images/") + filename);
                    thePicture.SaveAs(path);
                    // TODO: Add update logic here
                    Models.Profile theClient = db.Profiles.SingleOrDefault(c => c.person_id == id);
                    theClient.first_name  = collection["first_name"];
                    theClient.last_name   = collection["last_name"];
                    theClient.notes       = collection["notes"];
                    theClient.gender      = collection["gender"];
                    theClient.profile_pic = filename;

                    db.SaveChanges();
                }
                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
コード例 #5
0
        // GET: Address
        public ActionResult Index(int id)
        {
            ViewBag.id = id;

            Models.Profile theProfile = database.Profiles.SingleOrDefault(p => p.profile_id == id);
            return(View(theProfile));
        }
コード例 #6
0
        public ActionResult Index(int id)
        {
            ViewBag.id = id;
            Session["Address_person_id"] = id;
            Models.Profile theClient = db.Profiles.SingleOrDefault(c => c.person_id == id);

            return(View(theClient));
        }
コード例 #7
0
        public ActionResult LikeCommentIndex()
        {
            int id = int.Parse(Session["user_id"].ToString());

            Models.Profile thePicture = database.Profiles.SingleOrDefault(p => p.user_id == id);
            ViewBag.theCommentLike = database.Comment_Like;
            return(View(thePicture));
        }
コード例 #8
0
 public Task <List <Models.Company> > GetCompanyAsync(Models.Profile model)
 {
     return(Task.Factory.StartNew(() =>
     {
         var res = RestClient.Post <List <Models.Company> >(HttpWebRequest.Create(EndPointsList.ProfileDetailUrl), string.Empty, model.ToJson());
         return res;
     }));
 }
コード例 #9
0
        public ActionResult Contact()
        {
            var profile = new Models.Profile();

            ViewBag.Title   = "Welcome To Business Technology";
            ViewBag.Message = "This is my contact page.";
            return(View(profile));
        }
コード例 #10
0
        public ActionResult FriendRequestIndex()
        {
            int id = int.Parse(Session["user_id"].ToString());

            Models.Profile theProfile = database.Profiles.SingleOrDefault(p => p.user_id == id);
            ViewBag.theFollowers = database.FriendLinks;
            return(View(theProfile));
        }
コード例 #11
0
        public void AddDog(Models.Profile profile, Models.HotDog dog)
        {
            DAL.HotDog hotdogDAL = ConvertUtil.hotdogmodel2dal(dog);

            DAL.Profile profileDAO = db.Profiles.Find(profile.ProfileID);
            profileDAO.HotDogs.Add(hotdogDAL);
            db.SaveChanges();
        }
コード例 #12
0
        public Models.Teacher CreateTeacher(Guid divisionId, string firstName, string lastName, string email, string phone, string highlightColor, bool isActive)
        {
            Division division = this.DataContext.Get <Division>().Where(x => x.Id == divisionId).FirstOrDefault();

            if (division == null)
            {
                throw new InvalidOperationException($"Division ({divisionId}) does not exist.");
            }

            if (String.IsNullOrEmpty(highlightColor))
            {
                Random rand = new Random();
                highlightColor = Commons.Ultility.GetHighlightColor(rand);
            }
            Models.Profile profile = new Models.Profile()
            {
                Id             = Guid.NewGuid(),
                FirstName      = firstName,
                LastName       = lastName,
                Email          = email,
                Phone          = phone,
                HighlightColor = highlightColor,
                IsDeleted      = false
            };

            Models.Account account = new Models.Account()
            {
                Id        = Guid.NewGuid(),
                Profile   = profile,
                IsActive  = isActive,
                IsDeleted = false
            };

            Models.Teacher teacher = new Models.Teacher()
            {
                Id        = Guid.NewGuid(),
                Account   = account,
                IsActive  = isActive,
                IsDeleted = false,
            };

            TeacherDivision teacherDivision = new TeacherDivision()
            {
                Id         = Guid.NewGuid(),
                TeacherId  = teacher.Id,
                DivisionId = divisionId
            };

            teacher.TeacherDivisions.Add(teacherDivision);

            this.DataContext.Insert <Models.Profile>(profile);
            this.DataContext.Insert <Models.Account>(account);
            this.DataContext.Insert <Models.Teacher>(teacher);
            this.DataContext.Insert <TeacherDivision>(teacherDivision);

            return(teacher);
        }
コード例 #13
0
        public ActionResult privacyOn(int id)
        {
            Models.Profile theClient = db.Profiles.SingleOrDefault(c => c.person_id == id);

            theClient.privacy_flag = "On";
            db.SaveChanges();

            return(View("Index", theClient));
        }
コード例 #14
0
        public async Task RemoveProfile(Models.Profile profile)
        {
            if (File.Exists(profile.Image))
            {
                File.Delete(profile.Image);
            }

            await _repository.Remove(profile);
        }
コード例 #15
0
        public async Task <IActionResult> OnPostAsync()
        {
            Models.Profile ProfileToUpdate = await Context.Profiles.Where(p => p.ProfileID == UserManager.GetUserId(User)).FirstOrDefaultAsync();

            ProfileToUpdate.Introduction = Profile.Introduction;

            using (var memoryStream = new MemoryStream())
            {
                if (FileUpload.FormFile != null)
                {
                    await FileUpload.FormFile.CopyToAsync(memoryStream);
                }

                // Upload the file if less than 260 KB
                if (memoryStream.Length < 262144)
                {
                    if (memoryStream.Length != 0)
                    {
                        ProfileToUpdate.Image = memoryStream.ToArray();
                    }
                }
                else
                {
                    ModelState.AddModelError("FileUpload", "圖片檔案必須小於260KB");
                    return(Page());
                }
            }

            using (var memoryStream = new MemoryStream())
            {
                if (BannerUpload.FormFile != null)
                {
                    await BannerUpload.FormFile.CopyToAsync(memoryStream);
                }

                // Upload the file if less than 260 KB
                if (memoryStream.Length < 262144)
                {
                    if (memoryStream.Length != 0)
                    {
                        ProfileToUpdate.BannerImage = memoryStream.ToArray();
                    }
                }
                else
                {
                    ModelState.AddModelError("BannerUpload", "圖片檔案必須小於260KB");
                    return(Page());
                }
            }

            Context.Attach(ProfileToUpdate).State = EntityState.Modified;
            await Context.SaveChangesAsync();

            StatusMessage = "更改資料成功";
            return(RedirectToPage("./Index", "OnGet", new { id = ProfileToUpdate.ProfileID }));
        }
コード例 #16
0
 private static ProfileAggregate GetProfile(Models.Profile profile)
 {
     return(new ProfileAggregate
     {
         AuthUrl = profile.AuthUrl,
         OpenidUrl = profile.OpenIdUrl,
         ScimUrl = profile.ScimUrl,
         Subject = profile.Subject
     });
 }
コード例 #17
0
        public ActionResult UnLikePicture(int id)
        {
            Models.Like    likePicture = database.Likes.SingleOrDefault(p => p.picture_id == id);
            Models.Picture thePicture  = database.Pictures.SingleOrDefault(p => p.picture_id == id);
            Models.Profile theProfile  = database.Profiles.SingleOrDefault(p => p.picture_id == id);
            database.Likes.Remove(likePicture);
            database.SaveChanges();

            return(RedirectToAction("Index", new { id = thePicture.profile_id }));
        }
コード例 #18
0
        private async Task DeleteProfile(string userId)
        {
            Models.Profile ProfileToBeDeleted = await _context
                                                .Profiles
                                                .Where(p => p.ProfileID == userId)
                                                .FirstOrDefaultAsync();

            _context.Remove(ProfileToBeDeleted);
            await _context.SaveChangesAsync();
        }
コード例 #19
0
        public async Task <IActionResult> Edit(EditUserViewModel profileData)
        {
            try
            {
                var profile = new Models.Profile
                {
                    FirstName   = profileData.FirstName,
                    LastName    = profileData.LastName,
                    Gender      = profileData.Gender,
                    Id          = profileData.Id,
                    DisplayName = profileData.DisplayName,
                    Title       = profileData.Title
                };

                DateTimeOffset formattedDate;

                if (DateTimeOffset.TryParse(profileData.BirthDateString, out formattedDate))
                {
                    profile.BirthDate = formattedDate;
                }
                else
                {
                    profile.BirthDate = profileData.BirthDate;
                }

                if (profileData.PhoneNumber?.Number != null)
                {
                    profile.PhoneNumbers.Add(profileData.PhoneNumber);
                }

                if (profileData.Email != profileData.EmailRecord)
                {
                    var updateEmailSuccess = await _authClient.UpdateUserEmail(profileData.Id, profileData.Email);

                    if (!updateEmailSuccess)
                    {
                        return(RedirectToAction("Index", "Error"));
                    }
                }

                var success = await _demoClient.UpdateProfile(profile);

                if (success)
                {
                    return(RedirectToAction("Index", "UserManagement", new { id = profileData.Id.ToString() }));
                }

                return(RedirectToAction("Index", "Error"));
            }
            catch (Exception e)
            {
                return(RedirectToAction("Index", "Error"));
            }
        }
コード例 #20
0
 public ActionResult Detail()
 {
     Models.Profile item = new Models.Profile()
     {
         ID          = 1,
         NamaLengkap = "Ahmad Roni",
         Alamat      = "Jakarta",
         Hobi        = "hiking"
     };
     return(View(item));
 }
コード例 #21
0
        public ActionResult AllUsers(string errorMessage)
        {
            int personId = Int32.Parse(Session["person_id"].ToString());

            Models.Profile theUser = db.Profiles.SingleOrDefault(c => c.person_id == personId);

            ViewBag.error = errorMessage;


            return(View(db.Profiles));
        }
コード例 #22
0
        public void Update(Models.Profile profile)
        {
            var record2update = db.Profiles.Find(profile.ProfileID);

            if (record2update != null)
            {
                record2update.Name    = profile.Name;
                record2update.Picture = profile.Picture;
                record2update.Bio     = profile.Bio;
                db.SaveChanges();
            }
        }
コード例 #23
0
        public ActionResult UnFollowUser(int id)
        {
            int user_id = int.Parse(Session["user_id"].ToString());

            Models.Profile    theProfile = database.Profiles.SingleOrDefault(p => p.user_id == user_id);
            Models.FriendLink theFriend  = database.FriendLinks.SingleOrDefault(p => p.requested == id);
            database.FriendLinks.Remove(theFriend);

            database.SaveChanges();

            return(RedirectToAction("Index", new { id = theProfile.profile_id }));
        }
コード例 #24
0
        public ActionResult CreateFriendLink(int id)
        {
            int    personId = Int32.Parse(Session["person_id"].ToString());
            string error    = "";

            Models.FriendLink theLinkRequester = db.FriendLinks.SingleOrDefault(c => c.requester == personId && c.requested == id);
            Models.FriendLink theLinkRequested = db.FriendLinks.SingleOrDefault(c => c.requester == id && c.requested == personId);



            Models.Profile theRequested = db.Profiles.SingleOrDefault(c => c.person_id == id);

            Models.FriendLink newLink;
            if (theLinkRequester == null && theLinkRequested == null)
            {
                if (theRequested.privacy_flag.Equals("On"))
                {
                    newLink = new Models.FriendLink()
                    {
                        requester = personId,
                        requested = id,
                        approved  = "Pending",
                        status    = "Strangers",
                        read      = "Not read",
                        timestamp = DateTime.Now.ToString()
                    };
                }
                else
                {
                    newLink = new Models.FriendLink()
                    {
                        requester = personId,
                        requested = id,
                        approved  = "true",
                        status    = "Friends",
                        read      = "Not read",
                        timestamp = DateTime.Now.ToString()
                    };
                }
                db.FriendLinks.Add(newLink);
                db.SaveChanges();

                return(RedirectToAction("AllUsers", new { errorMessage = error }));
            }
            else
            {
                Models.Profile theProfile = db.Profiles.SingleOrDefault(p => p.person_id == id);
                error = "You have already sent/received a friend request to/from " + theProfile.first_name + " " + theProfile.last_name;

                return(RedirectToAction("AllUsers", new { errorMessage = error }));
            }
        }
コード例 #25
0
        public ActionResult AddCoWorker(Guid id)
        {
            // make sure the user is not attempting to add himself as a friend

            if (id == UserHelpers.GetUserId(User.Identity.Name))
            {
                TempData["errorMessage"] = "It is not possible to add yourself as a coworker. Sorry, system limitation better yet system violation";
                return(RedirectToAction("Coworkers"));
            }

            Models.Profile profile = UserHelpers.GetUserProfile(id);
            return(View(profile));
        }
コード例 #26
0
        public ActionResult Index(FormCollection collection)
        {
            //find the user record
            string username = collection["username"];

            Models.User theUser = database.Users.SingleOrDefault(u => u.username.Equals(username));

            if (theUser != null && Crypto.VerifyHashedPassword(theUser.password_hash, collection["password_hash"]))
            {
                Session["user_id"] = theUser.user_id;
                int            id         = int.Parse(Session["user_id"].ToString());
                Models.Profile theProfile = database.Profiles.SingleOrDefault(u => u.user_id == id);

                //Verifying if the profile for this user already exists
                if (theProfile != null)
                {
                    //If yes, return to profile index
                    return(RedirectToAction("Index", "Profile"));
                }

                //Verifying if the validation code is not null
                if (theUser.secret != null)
                {
                    Totp   totp    = new Totp(theUser.secret);
                    string theCode = totp.AuthenticationCode;
                    //If yes not null, return the user to profile index
                    if (theCode.Equals(collection["validation"]))
                    {
                        Session["user_id"] = theUser.user_id;
                        return(RedirectToAction("Index", "Profile"));
                    }
                    //If yes null, return an error message
                    else
                    {
                        ViewBag.error = "Wrong Username/Password/2FA combination!";
                        return(View());
                    }
                }
                //If not, return to profile creation
                else
                {
                    Session["user_id"] = theUser.user_id;
                    return(RedirectToAction("Create", "Profile"));
                }
            }
            else
            {
                ViewBag.error = "Wrong Username/Password combination!";
                return(View());
            }
        }
コード例 #27
0
ファイル: Index.cshtml.cs プロジェクト: Lauyea/involver
        public async Task <IActionResult> OnGetAsync()
        {
            user = await _userManager.GetUserAsync(User);

            if (user == null)
            {
                return(NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'."));
            }
            Profile = await Context.Profiles.Where(p => p.ProfileID == user.Id).FirstOrDefaultAsync();

            await LoadAsync(user);

            return(Page());
        }
コード例 #28
0
        public IHttpActionResult PutLunchProfile(int id, Models.Profile lunchProfile)
        {
            var profile = new LunchProfile()
            {
                Id            = lunchProfile.Id,
                Fav1          = lunchProfile.Fav1,
                Fav2          = lunchProfile.Fav2,
                Fav3          = lunchProfile.Fav3,
                FirstName     = lunchProfile.FirstName,
                FK_LocationId = lunchProfile.FK_LocationId,
                FK_OfficeId   = lunchProfile.FK_OfficeId,
                FK_ProviderId = lunchProfile.FK_ProviderId,
                LastName      = lunchProfile.LastName,
                Login         = lunchProfile.Login,
                LunchOrders   = lunchProfile.LunchToOrder.Select(x => new Models.EF.LunchOrder()
                {
                    DateOrdered = x.DateOrdered, FK_ProfileId = x.FK_ProfileId, Id = x.Id, Lunch = x.LunchOrder, LunchDay = x.LunchDay
                }).ToList()
            };

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != profile.Id)
            {
                return(BadRequest());
            }

            db.Entry(profile).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!LunchProfileExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #29
0
        public ActionResult _EditProfilePartial()
        {
            var manager     = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(db));
            var currentUser = manager.FindById(User.Identity.GetUserId());

            Profile profile = db.Profiles.SingleOrDefault(p => p.User.Id == currentUser.Id);

            if (profile == null)
            {
                profile = new Models.Profile();
            }

            return(View(profile));
        }
コード例 #30
0
		private async void Page_Loaded(object sender, RoutedEventArgs e)
		{
			Models.Profile _profile = await Common.StorageService.RetrieveObjectAsync<Models.Profile>("Profile");
			if (_profile == null)
			{
				_profile = await Models.Profile.GetProfile();
			}

			if (_profile != null)
			{
				ProfileObject = _profile;
			}

			GetEventCheckInData();
		}
コード例 #31
0
        public Models.ProfileModel t()
        {
            Logger.Info($"Instance Created");

            Account.Models.Profile p = new Models.Profile()
            {
                FirstName = "System",
                LastName  = "Admin",
                Email     = "*****@*****.**"
            };

            var dest = Mapper.Map <Models.Profile, Models.ProfileModel>(p);

            return(dest);
        }
コード例 #32
0
ファイル: Profile.xaml.cs プロジェクト: wvannigtevegt/S2M_UWP
		public Profile() {
			this.InitializeComponent();

			ProfileObject = new Models.Profile();
			TagList = new ObservableCollection<string>();
        }