Ejemplo n.º 1
0
 public void CreateContactDetail(CDYNewsDbContext context)
 {
     if (context.ContactDetails.Count() == 0)
     {
         try
         {
             var contactDetail = new ContactDetail()
             {
                 Name    = "Trang tin tức trường Cao đẳng Y tế Quảng Nam.",
                 Address = "3 Nguyễn Du, Phường An Mỹ, Tam Kỳ, Quảng Nam",
                 Email   = "*****@*****.**",
                 Lat     = 15.5723344,
                 Lng     = 108.4746795,
                 Phone   = "+84 235 3828 267",
                 Website = "cdytqn.edu.vn",
                 Other   = "",
                 Status  = true
             };
             context.ContactDetails.Add(contactDetail);
             context.SaveChanges();
         }
         catch (Exception)
         {
             throw;
         }
     }
 }
Ejemplo n.º 2
0
        public void addPage(CDYNewsDbContext context)
        {
            var page = new Page()
            {
                Name        = "Giới thiệu",
                Alias       = "gioi-thieu",
                Content     = "Nội dung trang giới thiệu",
                Status      = true,
                CreatedDate = DateTime.Now
            };

            context.Pages.Add(page);
            context.SaveChanges();
        }
Ejemplo n.º 3
0
        public void SendFeebback([FromBody] FeedbackViewModel feedbackViewModel)
        {
            if (ModelState.IsValid)
            {
                Feedback feedback = new Feedback();
                feedback.UpdateFeedback(feedbackViewModel);
                feedback.Status      = true;
                feedback.CreatedDate = DateTime.Now;
                CDYNewsDbContext db = new CDYNewsDbContext();
                db.Feedbacks.Add(feedback);
                db.SaveChanges();
                var toEmail = feedbackViewModel.Email;
                MailHelper.SendMail(toEmail, "Cảm ơn bạn đã gửi phản hồi", "Chúng tôi đã nhận được phản hồi từ bạn.");
            }
            else
            {
            }

            //var responseData = Mapper.Map<Feedback, FeedbackViewModel>(feedback);
        }
Ejemplo n.º 4
0
        protected override void Seed(CDYNewsDbContext context)
        {
            //addPage(context);
            //CreateContactDetail(context);
            //  This method will be called after migrating to the latest version.

            //  You can use the DbSet<T>.AddOrUpdate() helper extension method
            //  to avoid creating duplicate seed data.
            //var manager = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(new CDYNewsDbContext()));

            //var roleManager = new RoleManager<IdentityRole>(new RoleStore<IdentityRole>(new CDYNewsDbContext()));

            //var user = new ApplicationUser()
            //{
            //    UserName = "******",
            //    Email = "*****@*****.**",
            //    EmailConfirmed = true,
            //    FullName = "Le Xuan Hoang"

            //};

            //manager.Create(user, "Xuanhoang!23");

            //if (!roleManager.Roles.Any())
            //{
            //    roleManager.Create(new ApplicationRole { Name = "ViewUsers" });
            //    roleManager.Create(new ApplicationRole { Name = "AddUsers" });
            //    roleManager.Create(new ApplicationRole { Name = "UpdateUsers" });
            //    roleManager.Create(new ApplicationRole { Name = "DeleteUsers" });
            //}
            //if (!context.ApplicationGroups.Any())
            //{
            //    context.ApplicationGroups.Add(new ApplicationGroup { Name = "Admin" });
            //    context.ApplicationGroups.Add(new ApplicationGroup { Name = "User" });
            //}
            //var adminUser = manager.FindByEmail("*****@*****.**");

            //manager.AddToRoles(adminUser.Id, new string[] { "Admin", "User" });
        }
Ejemplo n.º 5
0
 public ApplicationUserStore(CDYNewsDbContext context)
     : base(context)
 {
 }
Ejemplo n.º 6
0
 public CDYNewsDbContext Init()
 {
     return(dbContext ?? (dbContext = new CDYNewsDbContext()));
 }