Пример #1
0
        public static void Seed(this diaryAppContext dbContext)
        {
            // add User
            dbContext.Users.Add(new Users
            {
                Id       = "testUser1",
                Fname    = "UserFirstname1",
                Lname    = "UserLastname1",
                Nickname = "UserNickName1",
                Email    = "*****@*****.**",
                Password = GetHashpassword("12345")
            });

            dbContext.SaveChangesAsync();


            // add Event
            dbContext.Events.Add(new Events
            {
                EventName = "testEvent1",
                DateTime  = new DateTime(2008 - 05 - 01),
                Memo      = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc nec tristique tellus, eget interdum massa. In hac habitasse platea dictumst. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce convallis felis dignissim egestas tristique. Quisque elementum sed diam ac varius. Sed sollicitudin venenatis sodales. Maecenas malesuada metus vitae tellus accumsan, et cursus mauris tincidunt. Suspendisse in nibh luctus, maximus mauris eu, efficitur justo. Morbi eu justo sed quam sodales mollis. Nulla eget suscipit nisl. Nam efficitur vestibulum orci, quis placerat nibh ultricies sit amet. In hac habitasse platea dictumst. Vivamus vel accumsan nisi.",
                UserId    = "testUser1"
            });


            dbContext.SaveChangesAsync();
        }
Пример #2
0
        public async Task <Users> Register(Users newUser)
        {
            var user = new Users()
            {
                Id           = Guid.NewGuid().ToString(),
                Fname        = newUser.Fname,
                Lname        = newUser.Lname,
                Nickname     = newUser.Nickname,
                Birthdate    = newUser.Birthdate,
                Email        = newUser.Email,
                Password     = newUser.Password,
                ProfileImage = newUser.ProfileImage
            };


            try
            {
                db.Add(user);
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException err) {
                throw err;
            }

            return(newUser);
        }
Пример #3
0
        public async Task <Events> addEvent(Events eventObj)
        {
            try
            {
                var userObj = db.Users.Single(u => u.Id == eventObj.UserId);
            }
            catch (Exception err)
            {
                throw err;
            }

            var ev = new Events()
            {
                DateTime  = eventObj.DateTime,
                EventName = eventObj.EventName,
                Memo      = eventObj.Memo,
                UserId    = eventObj.UserId
            };

            db.Add(ev);
            await db.SaveChangesAsync();

            return(ev);
        }