private void DeleteToDo(ToDoViewModel viewModel)
 {
     ToDoRepository.DeleteModel(viewModel.ToToDoModel());
     AllModels.Remove(viewModel);
     LoadActiveToDoForSelectedDate(CalendarViewModel.LastSelectedDate);
     LoadCompletedToDoForSelectedDate(CalendarViewModel.LastSelectedDate);
     RefreshMonthDaysForToDo(viewModel);
 }
Beispiel #2
0
        public ActionResult DatabaseAuthentication(AllModels model)
        {
            string ConnectionString = Server.MapPath("~/DatabaseConnection/ConnectionString.txt");
            string Username         = Server.MapPath("~/DatabaseConnection/Username.txt");
            string Password         = Server.MapPath("~/DatabaseConnection/Password.txt");

            string AdminUser = Server.MapPath("~/DatabaseConnection/AdminUser.txt");
            string AdminPass = Server.MapPath("~/DatabaseConnection/AdminPassword.txt");

            string AdminUserName = System.IO.File.ReadAllText(AdminUser);
            string AdminPassword = System.IO.File.ReadAllText(AdminPass);

            string User2 = EncryptionAndDecryption.Decrypt(AdminUserName);
            string Pass2 = EncryptionAndDecryption.Decrypt(AdminPassword);

            if (model.Maintenance.AdminUser != User2.ToString().TrimEnd() && model.Maintenance.AdminPassword != Pass2.ToString().TrimEnd())
            {
                ViewBag.HeaderError  = string.Format("Unable  to connect to server.");
                ViewBag.MessageError = string.Format("Check your Admin Username or Admin Password.");
                return(View());
            }


            using (StreamWriter sw = System.IO.File.CreateText(ConnectionString))
            {
                sw.WriteLine(model.Maintenance.DatabaseConnection);
            }

            using (StreamWriter sw = System.IO.File.CreateText(Username))
            {
                sw.WriteLine(EncryptionAndDecryption.Encrypt(model.Maintenance.DatabaseUser));
            }

            using (StreamWriter sw = System.IO.File.CreateText(Password))
            {
                sw.WriteLine(EncryptionAndDecryption.Encrypt(model.Maintenance.DatabasePassword));
            }

            DBConnection();

            using (SqlConnection connection = new SqlConnection(con))
            {
                try
                {
                    connection.Open();
                }
                catch
                {
                    ViewBag.HeaderError  = string.Format("Unable  to connect to server.");
                    ViewBag.MessageError = string.Format("Check your server connection.");
                    return(View());
                }
            }

            ViewBag.HeaderSuccess  = string.Format("Connection Success.");
            ViewBag.MessageSuccess = string.Format("Your Connection Server has connected.");
            return(View());
        }
Beispiel #3
0
        public IActionResult newDish()
        {
            AllModels chefs = new AllModels()
            {
                allChefs = dbContext.Chefs.ToList()
            };

            return(View(chefs));
        }
Beispiel #4
0
        public IActionResult Index()
        {
            AllModels chefs = new AllModels()
            {
                allChefs = dbContext.Chefs.Include(dish => dish.ChefRecipes).ToList()
            };

            return(View(chefs));
        }
        public void LoadAllToDoForSelectedDate(DateTime selectedDate)
        {
            var allToDos = GetAllToDoFromDatabase(x =>
                                                  x.WhenHappens.Year == selectedDate.Year &&
                                                  x.WhenHappens.Month == selectedDate.Month &&
                                                  x.WhenHappens.Day == selectedDate.Day);

            AllModels.ReplaceRangeWithoutUpdating(allToDos);
            AllModels.RaiseCollectionChanged();
        }
Beispiel #6
0
 //Gets cloud model data from cloud json file
 void readCloudJSON()
 {
     if (File.Exists(cloudJsonFilePath))
     {
         string dataAsJson = File.ReadAllText(cloudJsonFilePath);
         cloudModels = JsonUtility.FromJson <AllModels>(dataAsJson);
         populateModelBrowser(cloudModels, false);
     }
     else
     {
         Debug.LogError("Cannot load model data!");
     }
 }
Beispiel #7
0
        void UpdateStatistics()
        {
            StatisticsViewModel stat = new StatisticsViewModel();

            foreach (var e in AllModels.Where(z => z.Selected))
            {
                stat.EpisodesCount += e.Model.Montage.Information.Episodes.Count;
                stat.TotalClean    += (int)e.Model.Montage.Information.Episodes.Sum(z => z.Duration.TotalMinutes);
                stat.TotalDirty    += e.Model.Montage.Chunks.Where(z => z.Mode != Mode.Undefined).Sum(z => z.Length) / 60000;
            }
            Statistics = stat;
            this.NotifyByExpression(z => z.Statistics);
        }
Beispiel #8
0
 //Gets local model data from local json file
 void readLocalJSON()
 {
     if (File.Exists(localJsonFilePath))
     {
         string dataAsJson = File.ReadAllText(localJsonFilePath);
         localModels = JsonUtility.FromJson <AllModels>(dataAsJson);
         populateModelBrowser(localModels, true);
     }
     else
     {
         Debug.LogError("Cannot load model data!");
     }
 }
        public IActionResult About()
        {
            ViewData["Message"] = "Your application description page.";
            AllModels allModels = new AllModels();

            allModels.Restaurants   = DineOutContext.Restaurant.ToList();
            allModels.Customers     = DineOutContext.Customer.ToList();
            allModels.Orders        = DineOutContext.Order.ToList();
            allModels.OrderStatuses = DineOutContext.OrderStatus.ToList();
            allModels.Menus         = DineOutContext.Menu.ToList();
            allModels.Items         = DineOutContext.Item.ToList();
            allModels.Order_Items   = DineOutContext.Order_Item.ToList();
            return(View(allModels));
        }
Beispiel #10
0
        public void SetAllLists(Manager manager)
        {
            if (SelectedModelId != 0)
            {
                var selectedModel = manager.GetModel(SelectedModelId);
                AllModels.Add(new SelectListItem {
                    Value = selectedModel.Id.ToString(), Text = selectedModel.Name
                });
            }
            //makes
            foreach (var make in manager.GetAllMakes())
            {
                AllMakes.Add(new SelectListItem {
                    Value = make.Id.ToString(), Text = make.Name
                });
            }
            //models

            //conditions
            foreach (var condition in manager.GetAllConditions())
            {
                AllConditions.Add(new SelectListItem {
                    Value = condition.Id.ToString(), Text = condition.Name
                });
            }

            //styles
            foreach (var style in manager.GetAllBodyStyles())
            {
                AllStyles.Add(new SelectListItem {
                    Value = style.Id.ToString(), Text = style.Name
                });
            }

            //colors
            foreach (var color in manager.GetAllColors())
            {
                AllColors.Add(new SelectListItem {
                    Value = color.Id.ToString(), Text = color.Name
                });
            }

            //transmissions
            foreach (var trans in manager.GetAllTransmissions())
            {
                AllTransmissions.Add(new SelectListItem {
                    Value = trans.Id.ToString(), Text = trans.Name
                });
            }
        }
Beispiel #11
0
        public IEntity FindModelEntity(string modelName)
        {
            foreach (var generator in NamesGenerators)
            {
                var modelNameToSearch = generator.GenerateObjectName(modelName);

                if (AllModels.TryGetValue(modelNameToSearch, out var model))
                {
                    return(model.Entity);
                }
            }

            return(null);
        }
Beispiel #12
0
        public T FindModel <T>(string modelName)
            where T : Model
        {
            foreach (var generator in NamesGenerators)
            {
                var modelNameToSearch = generator.GenerateObjectName(modelName);

                if (AllModels.TryGetValue(modelNameToSearch, out var model))
                {
                    return((T)model);
                }
            }

            return(null);
        }
Beispiel #13
0
        public object DeSeriazlixeObject(FileStream file)
        {
            JsonSerializerSettings settings = new JsonSerializerSettings
            {
                TypeNameHandling           = TypeNameHandling.All,
                PreserveReferencesHandling = PreserveReferencesHandling.Objects
            };
            StreamReader reader = new StreamReader(file);

            file.Position = 0;
            string    content    = reader.ReadToEnd();
            AllModels newObjects = JsonConvert.DeserializeObject <AllModels>(content, settings);

            reader.Close();
            return(newObjects);
        }
Beispiel #14
0
        /// <summary>
        /// gets the selected profiles data
        /// </summary>
        /// <param name="id">url id(profile)</param>
        /// <param name="gameprofile">profile model</param>
        /// <returns>loads the partialview with the selected profile data</returns>
        public ActionResult GetProfileData(int?id, Gameprofile gameprofile)
        {
            if (id != null)
            {
                var SQLModel = new Gameprofile_SQL();
                SQLModel.FindProfile(id, gameprofile);
            }
            else
            {
                return(PartialView("PartialProfileData"));
            }

            AllModels allModels = new AllModels();

            allModels.Gameprofile = gameprofile;
            return(PartialView("PartialProfileData", allModels));
        }
Beispiel #15
0
        /// <summary>
        /// loads edit profile page with the selected profile data
        /// </summary>
        /// <param name="id">url id(profile)</param>
        /// <param name="gameprofile">profile model</param>
        /// <returns>edit page with the selected profile data</returns>
        public ActionResult EditProfile(int?id, Gameprofile gameprofile)
        {
            if (id != null)
            {
                var SQLModel = new Gameprofile_SQL();
                SQLModel.FindProfile(id, gameprofile);
            }
            else
            {
                return(View("Index"));
            }

            AllModels allModels = new AllModels();

            allModels.Gameprofile = gameprofile;
            return(View(allModels));
        }
Beispiel #16
0
        public IActionResult createDish(Dish newDish)
        {
            if (ModelState.IsValid)
            {
                dbContext.Add(newDish);
                dbContext.SaveChanges();

                return(RedirectToAction("Dish"));
            }
            else
            {
                AllModels chefs = new AllModels()
                {
                    allChefs = dbContext.Chefs.ToList()
                };
                return(View("newDish", chefs));
            }
        }
Beispiel #17
0
 void populateModelBrowser(AllModels models, bool local)
 {
     for (int i = 0; i < models.Models.Count; i++)
     {
         //Popluate the model panel
         if (local) //Local model
         {
             GameObject modelPanel = Instantiate(modelPanelPrefab, modelPanelPrefab.transform.position, Quaternion.identity, localScrollArea.transform);
             ModelPanel panel      = modelPanel.GetComponent <ModelPanel>();
             panel.populatePanel(this, models.Models[i], localIcon, true);
             localModelPanels.Add(panel);
         }
         else //Cloud model
         {
             GameObject modelPanel = Instantiate(modelPanelPrefab, modelPanelPrefab.transform.position, Quaternion.identity, cloudScrollArea.transform);
             ModelPanel panel      = modelPanel.GetComponent <ModelPanel>();
             panel.populatePanel(this, models.Models[i], cloudIcon, false);
             cloudModelPanels.Add(panel);
         }
     }
 }
Beispiel #18
0
        public IActionResult Wall()
        {
            if (HttpContext.Session.GetInt32("id") == null)
            {
                return(RedirectToAction("Logout", "User"));
            }
            ;
            AllModels ViewModels = new AllModels()
            {
                Comments = new Comment(),
                Messages = new Message()
            };

            List <Message> AllMessages = _context.messages.Include(u => u.Creator).Include(c => c.Comments).ToList();

            // List<Comment> AllComments = _context.comments.Include(m => m.BelongsTo).ToList();

            ViewBag.messages = AllMessages;

            System.Console.WriteLine(ViewModels);
            return(View(ViewModels));
        }
Beispiel #19
0
        public ActionResult LoginDatabase(AllModels model)
        {
            string AdminUser = Server.MapPath("~/DatabaseConnection/AdminUser.txt");
            string AdminPass = Server.MapPath("~/DatabaseConnection/AdminPassword.txt");

            string AdminUserName = System.IO.File.ReadAllText(AdminUser);
            string AdminPassword = System.IO.File.ReadAllText(AdminPass);

            string User2 = EncryptionAndDecryption.Decrypt(AdminUserName);
            string Pass2 = EncryptionAndDecryption.Decrypt(AdminPassword);

            if (model.Maintenance.AdminUser != User2.ToString().TrimEnd() || model.Maintenance.AdminPassword != Pass2.ToString().TrimEnd())
            {
                ViewBag.HeaderError  = string.Format("Unable  to connect to server.");
                ViewBag.MessageError = string.Format("Check your Admin Username or Admin Password.");
                return(View());
            }
            else
            {
                Session["AdminUser"] = User2;
                return(RedirectToAction("UpdateData", "Login"));
            }
        }
Beispiel #20
0
        private void DeSerialize_Click(object sender, RoutedEventArgs e)
        {
            string    fileName      = "";
            string    fileExtension = "";
            AllModels newObject     = new AllModels(null, null);


            OpenFileDialog openFileDialog = new OpenFileDialog();

            if (openFileDialog.ShowDialog() == true)
            {
                fileName = openFileDialog.FileName;
            }
            fileExtension = System.IO.Path.GetExtension(fileName);

            FileStream file = new FileStream(fileName, FileMode.Open, FileAccess.ReadWrite);

            foreach (var plugin in Plugins)
            {
                if (fileExtension.Substring(1, fileExtension.Length - 1) == plugin.Key.ToLower())
                {
                    file = plugin.Value.DeArchive(file, ref fileExtension);
                }
            }


            foreach (ISerializers serializer in Serializers)
            {
                string serializerExtension = serializer.Format.Substring(serializer.Format.LastIndexOf('.'), serializer.Format.Length - serializer.Format.LastIndexOf('.'));

                if (serializerExtension == fileExtension)
                {
                    SelectedSerializer = serializer;
                    newObject          = SelectedSerializer.DeSeriazlixeObject(file) as AllModels;
                    break;
                }
            }

            try
            {
                var modulesCount  = newObject.MyModules.Count;
                var vehiclesCount = newObject.MyVehicles.Count;
                for (int i = 0; i < modulesCount; i++)
                {
                    appViewModel.ModulesTab.Modules.Add(newObject.MyModules[i]);
                }
                for (int i = 0; i < vehiclesCount; i++)
                {
                    appViewModel.VehiclesTab.Vehicles.Add(newObject.MyVehicles[i]);
                }
            }
            catch
            {
            }

            file.Close();
            if (file.Name != fileName)
            {
                File.Delete(file.Name);
            }
        }
        public ActionResult Create(AllModels allModel)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    allModel.Odbior.Klient  = allModel.Odbiorca;
                    allModel.Nadanie.Klient = allModel.Nadawca;

                    allModel.Zlecenie.Odbior        = allModel.Odbior;
                    allModel.Zlecenie.Nadanie       = allModel.Nadanie;
                    allModel.Zlecenie.FK_Realizacja = 1;

                    var userId = User.Identity.GetUserId();
                    allModel.Zlecenie.Pracownik =
                        db.Pracownik.Where(p => p.FK_Uzytkownik.ToString().Equals(userId))
                        .FirstOrDefault();

                    var data = allModel.Odbior.Data;

                    bool przewozExists = false;
                    var  przewozy      =
                        db.Przewoz.Where(p => p.DataPrzewozu.Equals(data)).Where(s => (s.Paczka.Sum(p => p.Waga) + allModel.Paczka.Waga) < s.Samochod.Tonaz * 1000);
                    var przewoz = przewozy.FirstOrDefault();
                    if (przewoz == null)
                    {
                        var freeDriver =
                            db.Kierowca.Where(k => k.Przewoz.Where(p => p.DataPrzewozu.Equals(data)).Count() == 0)
                            .FirstOrDefault();

                        if (freeDriver == null)
                        {
                            allModel.ValidationSummary += data.ToShortDateString() +
                                                          ": nie znaleziono wolnego kierowcy. Zmień datę odbioru.";
                            return(View(allModel));
                        }
                        var freeCars =
                            db.Samochod.Where(s => s.Przewoz.Where(p => p.DataPrzewozu.Equals(data)).Count() == 0);
                        Samochod freeCar;
                        if (freeCars.Count() == 0)
                        {
                            allModel.ValidationSummary += data.ToShortDateString() +
                                                          ": nie znaleziono wolnego pojazdu. Zmień datę odbioru.";
                            return(View(allModel));
                        }
                        else
                        {
                            freeCar = freeCars.Where(s => s.Tonaz * 1000 > allModel.Paczka.Waga).FirstOrDefault();
                        }
                        if (freeCar == null)
                        {
                            allModel.ValidationSummary +=
                                "Nie posiadamy pojazdu który ma tonaż większy niż waga paczki.";
                            return(View(allModel));
                        }
                        przewoz = new Przewoz();
                        przewoz.DataPrzewozu = data;
                        przewoz.Kierowca     = freeDriver;
                        przewoz.Samochod     = freeCar;
                    }
                    else
                    {
                        przewozExists = true;
                    }

                    allModel.Paczka.Przewoz  = przewoz;
                    allModel.Paczka.Zlecenie = allModel.Zlecenie;
                    db.Paczka.Add(allModel.Paczka);
                    db.SaveChanges();
                }
                catch (Exception e) { }
            }
            return(View(allModel));
        }
Beispiel #22
0
        private void Serialize_Click(object sender, RoutedEventArgs e)
        {
            AllModels allModels = new AllModels(appViewModel.ModulesTab.Modules, appViewModel.VehiclesTab.Vehicles);

            string fileName      = "";
            string fileExtension = "";//StringBuilder
            string filter        = string.Join("|", Serializers.Select(x => x.Format));

            SaveFileDialog saveFileDialog = new SaveFileDialog();

            saveFileDialog.Filter = filter;
            if (saveFileDialog.ShowDialog() == true)
            {
                fileName = saveFileDialog.FileName;
            }
            //fileName = System.IO.Path.GetFileName(fileName);
            fileExtension = System.IO.Path.GetExtension(fileName);


            //CivilianVehicle testVehicle = new CivilianVehicle()
            //{
            //    Engine = new Engine()
            //    {
            //        Name = "Engine1",
            //        Power = 100,
            //        Vulnerability = "Good"
            //    },
            //    Name = "Civilian",
            //    Price = 200,
            //    SeatsCount = 3,
            //    Weight = "Big",
            //    Tracks = new Tracks()
            //    {
            //        Name = "Tracks1",
            //        Vulnerability = "Bad",
            //        WeightCapacity = 300
            //    }
            //};



            foreach (ISerializers serializer in Serializers)
            {
                string serializerExtension = serializer.Format.Substring(serializer.Format.LastIndexOf('.'), serializer.Format.Length - serializer.Format.LastIndexOf('.'));

                if (serializerExtension == fileExtension)
                {
                    SelectedSerializer = serializer;
                    SelectedSerializer.SerializeObject(allModels, fileName);
                    break;
                }
            }

            try
            {
                FileStream file = new FileStream(fileName, FileMode.Open, FileAccess.Read);


                foreach (var plugin in Plugins)
                {
                    if (comboBoxPlugins.SelectedItem == plugin.Key)
                    {
                        plugin.Value.Archive(file);
                        file.Close();
                        File.Delete(fileName);
                    }
                }
            }
            catch
            { }
        }
 private IEnumerable <ToDoViewModel> GetToDoModelsByCondition(Func <ToDoViewModel, bool> predicate) =>
 AllModels
 .Where(predicate)
 .OrderByDescending(x => x.WhenHappens);
Beispiel #24
0
 public static StageItemModel GetModelFromKey(string key)
 {
     return(AllModels.Find(x => x.JsonKey.Equals(key)));
 }
 /// <summary>
 /// Initialize by storing all the model chain inheritance paths for each model.
 /// </summary>
 public void Init()
 {
     AllModels.Init();
 }
Beispiel #26
0
        public ActionResult LoginAuthentication(MaintenanceModel maintenance)
        {
            var username = maintenance.Username;
            var password = maintenance.Password;

            //if (User.Identity.IsAuthenticated)
            //{
            //    return RedirectToAction("Dashboard", "Home");
            //}
            //System.Web.Helpers.AntiForgery.Validate();
            try
            {
                DBConnection();

                DBMaintenance dBMaintenance = new DBMaintenance();
                maintenance = dBMaintenance.UserAuthentication(maintenance);
            }
            catch
            {
                ViewBag.LoginAuthentication = "Login";
                ViewBag.HeaderError         = string.Format("Unable  to connect to server.");
                ViewBag.MessageError        = string.Format("Check your server connection settings.");

                ViewBag.UserField = username;
                return(View());
            }

            if (maintenance != null)
            {
                if (maintenance.Status == "2")
                {
                    ViewBag.LoginAuthentication = "Login";
                    ViewBag.HeaderError         = string.Format("Account Issue.");
                    ViewBag.MessageError        = string.Format("Your account has been inactive.");

                    ViewBag.UserField = username;
                    return(View());
                }

                else if (maintenance.ResetPassword == 1)
                {
                    if (maintenance.Code.Trim() == password || maintenance.Password.Trim() == "P@ssw0rd")
                    {
                        ViewBag.LoginAuthentication = "ResetPassword";
                        AllModels models = new AllModels();
                        models.Maintenance = maintenance;
                        return(View(models));
                    }
                    else
                    {
                        ViewBag.LoginAuthentication = "Login";
                        ViewBag.HeaderWarning       = string.Format("Reset Password.");
                        ViewBag.MessageWarning      = string.Format("Please Enter Code.");

                        ViewBag.UserField = username;
                        return(View());
                    }
                }
                else
                {
                    if (maintenance.Code == password)
                    {
                        ViewBag.LoginAuthentication = "Login";
                        ViewBag.HeaderError         = string.Format("Login Failed.");
                        ViewBag.MessageError        = string.Format("Username or Password is incorrect.");

                        ViewBag.UserField = username;
                        return(View());
                    }
                    else
                    {
                        Session["UserID"]          = maintenance.UserID;
                        Session["Fullname"]        = maintenance.Fullname;
                        Session["UserRoleID"]      = maintenance.RoleID;
                        Session["UserRole"]        = maintenance.RoleName;
                        Session["Department"]      = maintenance.DepartmentID;
                        Session["GroupID"]         = maintenance.GroupID;
                        Session["DesignationID"]   = maintenance.DesignationID;
                        Session["GroupName"]       = maintenance.Group;
                        Session["DesignationName"] = maintenance.Designation;

                        FormsAuthentication.SetAuthCookie(Session["UserID"].ToString(), false); // render Session into Authentication Cookie

                        SqlDependency.Start(con);
                        SqlDependency.Start(con2);
                        SqlDependency.Start(con3);
                        NotificationComponent NC = new NotificationComponent();
                        NC.group = maintenance.GroupID;
                        NC.Notificaton(maintenance.GroupID);
                        NC.UpdateItemRequestNotificaton();
                        NC.NotificatonItem();
                        NC.NotificatonUpdateItem();
                        return(RedirectToAction("Dashboard", "Home"));
                    }
                }
            }
            else
            {
                ViewBag.LoginAuthentication = "Login";
                ViewBag.HeaderError         = string.Format("Login Failed.");
                ViewBag.MessageError        = string.Format("Username or Password is incorrect.");

                ViewBag.UserField = username;
                return(View());
            }
        }