Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace E_Learning.Models
- {
- using System;
- using System.Collections.Generic;
- using E_Learning.Helpers;
- public partial class users
- {
- public string getHandle()
- {
- return Slugify.Make(this.first_name + ' ' + this.last_name);
- }
- public string full_name
- {
- get
- {
- return this.first_name + ' ' + this.last_name;
- }
- }
- private Nullable<int> age
- {
- get
- {
- DateTime now = DateTime.Today;
- if (this.birthday.HasValue)
- {
- DateTime birthday = DateTime.Parse(this.birthday.ToString());
- int age = now.Year - birthday.Year;
- if (now < birthday.AddYears(age))
- age--;
- return age;
- }
- return null;
- }
- }
- }
- }
- public ActionResult Index(Entities db)
- {
- string password = BCryptHelper.HashPassword("admin", BCryptHelper.GenerateSalt(8));
- users user = new users
- {
- first_name = "Rafael",
- last_name = "Alexandre",
- email = "rafael.alexandre@voxdigital.com.br",
- password = password,
- };
- user.handle = user.getHandle();
- db.Set<users>().Add(user);
- db.SaveChanges();
- return View("~/Views/Index.cshtml");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement