public ActionResult List(FormCollection formCollection)
        {
            if (formCollection["AnswerIds"] == null)
            {
                return(RedirectToAction("List"));
            }

            var result = new List <Application>();

            string[] ids = formCollection["AnswerIds"].Split(new char[] { ',' });


            using (ApplicationDB dbContext = new ApplicationDB())
            {
                var appEdit = dbContext.Applications.ToList();

                foreach (string id in ids)
                {
                    int currentId = 0;

                    if (int.TryParse(id, out currentId))
                    {
                        var editApp = dbContext.Applications.SingleOrDefault(a => a.Id == currentId);
                        editApp.IsAnswered = true;
                    }
                }
                dbContext.SaveChanges();

                result = dbContext.Applications.Include("User").ToList();
            }

            return(View(result));
        }
예제 #2
0
        /// <summary>
        /// Default values
        /// </summary>
        public FeederConfig()
        {
            Application = new ApplicationDB();
            Hardware    = new HardwareDB();

            AllControlSets = new ControlSetsDB();
        }
예제 #3
0
    public Boolean insertApplication(string applayDate, string name, string sex, string address, string birthDate, string education, string source, string state, string comment, double salary, int workHours, int mobilePhone, int phone, int familyPhone, string nationalID, byte[] image)
    {
        application   = new ApplicationForm();
        applicationDB = new ApplicationDB();
        sourceControl = new SourceControl();

        application.setName(name);
        application.setApplayDate(applayDate);
        application.setSex(sex);
        application.setAddress(address);
        application.setBirthDate(birthDate);
        application.setEducation(education);
        application.setSource(sourceControl.selectID(source));
        application.setState(state);
        application.setComment(comment);
        application.setSalary(salary);
        application.setWorkHours(workHours);
        application.setMobilePhone(mobilePhone);
        application.setPhone(phone);
        application.setFamilyPhone(familyPhone);
        application.setNationalID(nationalID);
        application.setImage(image);
        check = applicationDB.checkApplication(application);
        if (check == true)
        {
            return(false);
        }
        else
        {
            applicationDB.insert(application);
            return(true);
        }
    }
예제 #4
0
 public UnitOfWork(ApplicationDB db)
 {
     _db     = db;
     SP_Call = new SP_Call(_db);
     Tag     = new TagRepository(_db);
     Post    = new PostRepository(_db);
     User    = new UserRepository(_db);
 }
        public ActionResult List()
        {
            var result = new List <Application>();

            using (ApplicationDB dbContext = new ApplicationDB())
            {
                result = dbContext.Applications.Include("User").ToList();
            }
            return(View(result));
        }
        private string GetManagerEmail()
        {
            using (ApplicationDB dbContext = new ApplicationDB())
            {
                var user = dbContext.Users.Include("Roles").
                           Where(u => u.Roles.Any(r => r.Name.Contains("MANAGER"))).FirstOrDefault();


                return((user != null) ? user.Email : string.Empty);
            }
        }
        public async Task <ActionResult> Create(ApplicationView applicationView, HttpPostedFileBase image)
        {
            string message = string.Empty;
            bool   status  = false;

            if (ModelState.IsValid)
            {
                Application app = new Application();
                app.Created = DateTime.Now;
                app.Theme   = applicationView.Theme;
                app.Body    = applicationView.Body;
                app.UserId  = ((CustomPrincipal)HttpContext.User).Id;

                string emailTo = ((CustomPrincipal)HttpContext.User).Email;

                app.IsAnswered = false;
                if (image != null)
                {
                    app.FileName = image.FileName;
                    app.FileBody = new byte[image.ContentLength];
                    image.InputStream.Read(app.FileBody, 0, image.ContentLength);
                }

                using (ApplicationDB dbContext = new ApplicationDB())
                {
                    DateTime date = DateTime.Now.AddDays(-1);

                    var lastApp = dbContext.Applications.FirstOrDefault(a => a.Created > date);

                    if (lastApp == null)
                    {
                        dbContext.Applications.Add(app);
                        await dbContext.SaveChangesAsync();

                        status = true;
                        await SendEmail(app, emailTo);

                        message = "Ваша заявка успешно сохранена.";
                    }
                    else
                    {
                        message = $"Вы не можете создать заявку т.к. Можно создавать одну заявку в день. Последняя заявка была создана: {lastApp.Created}";
                    }
                }
            }
            else
            {
                message = "Упс! Что-то пошло не так...";
            }

            ViewBag.Status  = status;
            ViewBag.Message = message;
            return(View(applicationView));
        }
예제 #8
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            // Initializes and seeds the database.
            Database.SetInitializer(new DBInitializer());

            using (var context = new ApplicationDB()) {
                context.Database.Initialize(force: true);
            }

            RegisterGlobalFilters(GlobalFilters.Filters);
            RegisterRoutes(RouteTable.Routes);
        }
예제 #9
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            // Initializes and seeds the database.
            Database.SetInitializer(new DBInitializer());

            using (var context = new ApplicationDB()) {
                context.Database.Initialize(force: true);
            }

            RegisterGlobalFilters(GlobalFilters.Filters);
            RegisterRoutes(RouteTable.Routes);
        }
예제 #10
0
        public override MembershipUser GetUser(string username, bool userIsOnline)
        {
            using (ApplicationDB dbContext = new ApplicationDB())
            {
                var user = (from us in dbContext.Users.Include("Roles")
                            where string.Compare(username, us.Username, StringComparison.OrdinalIgnoreCase) == 0
                            select us).FirstOrDefault();

                if (user == null)
                {
                    return(null);
                }
                var selectedUser = new CustomMembershipUser(user);

                return(selectedUser);
            }
        }
예제 #11
0
        public ActionResult Registration(RegistrationView registrationView)
        {
            bool   statusRegistration  = false;
            string messageRegistration = string.Empty;

            if (ModelState.IsValid)
            {
                string userName = Membership.GetUserNameByEmail(registrationView.Email);
                if (!string.IsNullOrEmpty(userName))
                {
                    ModelState.AddModelError("Неверный Email", "Ошибка: Email уже существует");
                    return(View(registrationView));
                }

                using (ApplicationDB dbContext = new ApplicationDB())
                {
                    var user = new User()
                    {
                        Username = registrationView.Username,
                        Email    = registrationView.Email,
                        Password = registrationView.Password,
                        IsActive = true
                    };

                    var managerRole = (from roles in dbContext.Roles
                                       where string.Compare(roles.Name, ROLENAME, StringComparison.OrdinalIgnoreCase) == 0
                                       select roles).FirstOrDefault();
                    user.Roles.Add(managerRole);

                    dbContext.Users.Add(user);
                    dbContext.SaveChanges();
                }

                messageRegistration = "Аккаунт - успешно создан.";
                statusRegistration  = true;
            }
            else
            {
                messageRegistration = "Упс! Что-то пошло не так...";
            }
            ViewBag.Message = messageRegistration;
            ViewBag.Status  = statusRegistration;

            return(View(registrationView));
        }
예제 #12
0
        public override bool ValidateUser(string username, string password)
        {
            if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password))
            {
                return(false);
            }

            using (ApplicationDB dbContext = new ApplicationDB())
            {
                var user = (from us in dbContext.Users
                            where string.Compare(username, us.Username, StringComparison.OrdinalIgnoreCase) == 0 &&
                            string.Compare(password, us.Password, StringComparison.OrdinalIgnoreCase) == 0 &&
                            us.IsActive == true
                            select us).FirstOrDefault();

                return((user != null) ? true : false);
            }
        }
예제 #13
0
        static void Main(string[] args)
        {
            //Application RunPizzaApp = new Application();
            //Order CustomerOrder = RunPizzaApp.CreateOrder();
            //RunPizzaApp.ViewOrder(CustomerOrder);

            ApplicationDB RunPizzaDBApp = new ApplicationDB();

            //RunPizzaDBApp.CreateOrder();
            //RunPizzaDBApp.ViewIngredients();
            RunPizzaDBApp.ViewOrder();

            //TODO: Reflection to get list of classes in namespace.

            // Type NYPizza = typeof(NewYork);
            // object NYInstance = Activator.CreateInstance(NYPizza);
            // MethodInfo createNYPizza = NYPizza.GetMethod("Make");

            // TEST
            // NewYork NewYork1 = new NewYork();
            // Size NewYorkSize = new Size("Small");
            // List<Topping> NewYorkTopping  = new List<Topping> ();
            // NewYorkTopping.Add(new Topping("Cheese"));
            // NewYorkTopping.Add(new Topping("Ham"));
            // var NYStuff = NewYork1.Make(NewYorkSize, NewYorkTopping);

            // var NYReflect = createNYPizza.Invoke(NYInstance, new object[] {NewYorkSize, NewYorkTopping})

            // Logic to use reflection.
            // Order1 ReflectionOrder = new Order1();
            // ReflectionOrder.PizzaTable.Add(NYPizza.Name, NYReflect as List<AComponent>);
            // foreach (var KeyReflect in ReflectionOrder.PizzaTable.Keys)
            // {
            //     Console.WriteLine(KeyReflect);
            //     foreach (var ItemPizza in ReflectionOrder.PizzaTable.GetValueOrDefault(KeyReflect))
            //     {
            //         Console.WriteLine(ItemPizza.ToString());
            //     }
            // }
        }
예제 #14
0
        public override MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status)
        {
            User user = new User()
            {
                Username = username,
                Email    = email,
                Password = password,
                IsActive = true
            };

            using (ApplicationDB dbContext = new ApplicationDB())
            {
                var managerRole = (from roles in dbContext.Roles
                                   where string.Compare(roles.Name, ROLENAME, StringComparison.OrdinalIgnoreCase) == 0
                                   select roles).FirstOrDefault();
                user.Roles.Add(managerRole);
                dbContext.Users.Add(user);
                dbContext.SaveChanges();

                status = MembershipCreateStatus.Success;
                return(new CustomMembershipUser(user));
            }
        }
예제 #15
0
        public override string[] GetRolesForUser(string username)
        {
            if (!HttpContext.Current.User.Identity.IsAuthenticated)
            {
                return(null);
            }

            var userRoles = new string[] { };

            using (ApplicationDB dbContext = new ApplicationDB())
            {
                var selectedUser = (from us in dbContext.Users.Include("Roles")
                                    where string.Compare(us.Username, username, StringComparison.OrdinalIgnoreCase) == 0
                                    select us).FirstOrDefault();


                if (selectedUser != null)
                {
                    userRoles = new[] { selectedUser.Roles.Select(r => r.Name).ToString() };
                }

                return(userRoles.ToArray());
            }
        }
예제 #16
0
 public UserRepository(ApplicationDB db) : base(db)
 {
     _db = db;
 }
예제 #17
0
 public PostController(IUnitOfWork unitOfWork, IHostEnvironment hostEnvironment, ApplicationDB db)
 {
     _unitOfWork = unitOfWork;
     _hostEnvironment = hostEnvironment;
     _db = db;
 }
 public TblUsersController(ApplicationDB context)
 {
     _context = context;
 }
예제 #19
0
 public SP_Call(ApplicationDB db)
 {
     _db = db;
     ConnectionString = _db.Database.GetDbConnection().ConnectionString;
 }
예제 #20
0
 public Application_Users_Service(DbContext context) : base(context)
 {
     _context = (ApplicationDB)context;
 }
예제 #21
0
 public HomeController(ApplicationDB db)
 {
     _db = db;
 }
예제 #22
0
 public TblHotelsController(ApplicationDB context)
 {
     _context = context;
 }
 public TblGuidesController(ApplicationDB context)
 {
     _context = context;
 }
예제 #24
0
 public Repository(ApplicationDB db)
 {
     _db   = db;
     dbSet = _db.Set <T>();
 }
 public TblStatesController(ApplicationDB context)
 {
     _context = context;
 }
 public ProfileController(ApplicationDB dB, IUnitOfWork unitOfWork, IHostEnvironment hostEnvironment)
 {
     _db              = dB;
     _unitOfWork      = unitOfWork;
     _hostEnvironment = hostEnvironment;
 }
 public TblFoodTimeDetailsController(ApplicationDB context)
 {
     _context = context;
 }
 public TblPackageActivitiesController(ApplicationDB context)
 {
     _context = context;
 }
예제 #29
0
 public TblCitiesController(ApplicationDB context)
 {
     _context = context;
 }
예제 #30
0
 public UnitOfWork(ApplicationDB _context)
 {
     context = _context;
 }
예제 #31
0
 public PostRepository(ApplicationDB db) : base(db)
 {
     _db = db;
 }