public override MembershipUser GetUser(string email, bool userIsOnline) { try { var user = DataBase.GetClient(email); if (user == null) { return(null); } MembershipUser membershipUser = new MembershipUser("MyMembershipProvider", user.Email, null, null, null, null, false, false, DateTime.Now, DateTime.MinValue, DateTime.MinValue, DateTime.MinValue, DateTime.MinValue); return(membershipUser); //using (UserContext _db = new UserContext()) //{ // var users = from u in _db.Users // where u.Email == email // select u; // if (users.Count() > 0) // { // User user = users.First(); // MembershipUser memberUser = new MembershipUser("MyMembershipProvider", user.Email, null, null, null, null, // false, false, user.CreationDate, DateTime.MinValue, DateTime.MinValue, DateTime.MinValue, DateTime.MinValue); // return memberUser; // } //} } catch { return(null); } }
public ActionResult Index() { if (!User.Identity.IsAuthenticated) { return(View("Error")); } var client = _data.GetClient(User.Identity.Name); client.Rooms = _data.GetRoomsByUser(client.Id).ToList(); return(View(client)); }
public ActionResult UploadFile(string roomId) { var id = Guid.Parse(roomId); var room = _data.RoomById(id); Guid?userId = null; if (User.Identity.IsAuthenticated) { userId = _data.GetClient(User.Identity.Name)?.Id; } if (room == null) { _data.AddRoom(new Room { Id = id, DataCreated = DateTime.Now, ClientId = userId }); } foreach (string file in Request.Files) { HttpPostedFileBase upload = Request.Files[file]; if (upload != null) { string fileName = Path.GetFileName(upload.FileName); byte[] data; using (Stream inputStream = upload.InputStream) { MemoryStream memoryStream = inputStream as MemoryStream; if (memoryStream == null) { memoryStream = new MemoryStream(); inputStream.CopyTo(memoryStream); } data = memoryStream.ToArray(); } File filedb = new File(); filedb.RoomId = id; filedb.Id = Guid.NewGuid(); filedb.Name = fileName; filedb.FileType = GetFileType(fileName); filedb.FileBytes = data; _data.AddFile(filedb); } } return(View("Files", _data.GetFiles(id).ToArray())); }