Пример #1
0
        public ActionResult Create(ProjectType projecttype)
        {
            if (ModelState.IsValid)
            {
                db.ProjectTypes.Add(projecttype);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(projecttype));
        }
Пример #2
0
        public ActionResult Create([Bind(Include = "id,name")] Kryterium kryterium)
        {
            if (ModelState.IsValid)
            {
                db.Kryteria.Add(kryterium);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(kryterium));
        }
Пример #3
0
        public ActionResult Create([Bind(Include = "Id,Name,Branch,EducationalQualifications,Email,DOB")] Faculty faculty)
        {
            if (ModelState.IsValid)
            {
                db.Facultys.Add(faculty);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(faculty));
        }
Пример #4
0
        public ActionResult Create([Bind(Include = "ID,Nazwa,Opis")] Portal portal)
        {
            if (ModelState.IsValid)
            {
                db.Portale.Add(portal);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(portal));
        }
Пример #5
0
        public ActionResult SchrijfIn([Bind(Include = "deelnemer_id,voornaam,achternaam,email,evenement,goedgekeurd")] Deelnemer deelnemer)
        {
            if (ModelState.IsValid)
            {
                db.Deelnemers.Add(deelnemer);
                db.SaveChanges();
                return(RedirectToAction("Index", "Home", null));
            }

            return(View(deelnemer));
        }
Пример #6
0
        public ActionResult Create([Bind(Include = "Id,Name,DOB,Sem,Branch,Email,Phone")] Student student)
        {
            if (ModelState.IsValid)
            {
                db.Students.Add(student);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(student));
        }
Пример #7
0
        public ActionResult Create([Bind(Include = "ID,Nazwa,DataAnalizy")] Analiza analiza)
        {
            if (ModelState.IsValid)
            {
                db.Analizy.Add(analiza);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(analiza));
        }
Пример #8
0
        public ActionResult Create([Bind(Include = "Id,Name,Sem")] Subject subject)
        {
            if (ModelState.IsValid)
            {
                db.Subjects.Add(subject);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(subject));
        }
Пример #9
0
        public ActionResult Create([Bind(Include = "QuestionId,Description,Marks,Answer,Hint,Subject_Id")] Question question)
        {
            if (ModelState.IsValid)
            {
                question.Faculty_Id = (int)Session["UserID"];
                db.Questions.Add(question);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(question));
        }
Пример #10
0
        public ActionResult DeleteComfirmed(int id)
        {
            Wijziging wijziging = db.Wijzigings.Find(id);

            if (!db.IsAuthorized(wijziging.beheerder, User.Identity.GetUserId()))
            {
                return(new HttpStatusCodeResult(HttpStatusCode.Unauthorized));
            }
            db.Wijzigings.Remove(wijziging);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public ActionResult Create(ProjectActivity projectactivity)
        {
            if (ModelState.IsValid)
            {
                db.ProjectActivities.Add(projectactivity);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.OwnerUserID   = new SelectList(db.UserProfiles, "UserId", "UserName", projectactivity.OwnerUserID);
            ViewBag.ProjectTypeID = new SelectList(db.ProjectTypes, "ProjectTypeID", "Description", projectactivity.ProjectTypeID);
            return(View(projectactivity));
        }
Пример #12
0
        public ActionResult Create([Bind(Include = "beheerder_id,voornaam,achternaam,gebruikersnaam,wachtwoord")] Beheerder beheerder)
        {
            if (ModelState.IsValid)
            {
                db.Beheerders.Add(beheerder);
                db.SaveChanges();

                SignIn(beheerder.beheerder_id.ToString(), beheerder.gebruikersnaam);
                return(RedirectToAction("Index", "Home"));
            }

            return(View(beheerder));
        }
Пример #13
0
        public ActionResult Create([Bind(Include = "Id,Wartosc,AnalizaId,KryteriumId")] Waga waga)
        {
            if (ModelState.IsValid)
            {
                db.Wagi.Add(waga);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.AnalizaId   = new SelectList(db.Analizy, "Id", "Nazwa", waga.AnalizaId);
            ViewBag.KryteriumId = new SelectList(db.Kryteria, "Id", "Nazwa", waga.KryteriumId);
            return(View(waga));
        }
Пример #14
0
        public ActionResult Create([Bind(Include = "Id,Wartosc,Opis,KryteriumID,PortalId,AnalizaId")] Ocena_Kryterium ocena_Kryterium)
        {
            if (ModelState.IsValid)
            {
                db.OcenyKryterium.Add(ocena_Kryterium);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.KryteriumID = new SelectList(db.Kryteria, "Id", "Nazwa", ocena_Kryterium.KryteriumID);
            ViewBag.AnalizaId   = new SelectList(db.Analizy, "Id", "Nazwa", ocena_Kryterium.AnalizaId);
            ViewBag.PortalId    = new SelectList(db.Portale, "ID", "Nazwa", ocena_Kryterium.PortalId);
            return(View(ocena_Kryterium));
        }
Пример #15
0
        public bool CreateBlog(Blog blog)
        {
            bool result = false;

            try
            {
                _context.Blog.Add(blog);
                _context.SaveChanges();
                result = true;
            }
            catch
            {
            }
            return(result);
        }
Пример #16
0
        public ActionResult Create([Bind(Include = "Id,paperDate,Name,Description,isPublic,Subject_Id,Duration")] Paper paper, FormCollection form)
        {
            if (ModelState.IsValid)
            {
                paper.Faculty_Id = (int)Session["UserID"];
                paper.paperDate  = paper.paperDate.AddHours(Double.Parse(form["timehours"]));
                paper.paperDate  = paper.paperDate.AddMinutes(Double.Parse(form["timeminutes"]));
                db.Papers.Add(paper);
                db.SaveChanges();
                Session["id"] = paper.Id;
                return(RedirectToAction("AddQuestion", new { sid = db.Subjects.Find(paper.Subject_Id).Id }));
            }

            return(View(paper));
        }
Пример #17
0
        private void SeedCategory(DataModelContext context)
        {
            var defaultName = " Category ";

            var categories = new List <String> {
                "Men", "Women", "Kids", "Others"
            };

            var categoriesIds = new List <String>
            {
                "5110BE6C-00F4-46BA-B141-CC0B74B33EEF",
                "892F90E4-C533-49DE-A7EA-F1DD1DB7D01A",
                "042A2B12-1C92-465A-828C-69DCE587A1A7",
                "25457B16-486A-4153-85D1-F18F28802886"
            };

            for (var count = 0; count < 4; count++)
            {
                var category = new Category
                {
                    ID          = new Guid(categoriesIds[count]),
                    ShortName   = categories[count],
                    Code        = categories[count].Substring(0, 2),
                    Description = $"{categories[count]}{defaultName}"
                };

                context.Categories.AddOrUpdate(category);
            }

            context.SaveChanges();
        }
Пример #18
0
 public ActionResult Create([Bind(Include = "evenement_id,naam,beschrijving,begindatum,einddatum")] Evenement evenement)
 {
     if (ModelState.IsValid)
     {
         db.Evenements.Add(evenement);
         EvenementBeheerder evenementBeheerder = new EvenementBeheerder
         {
             evenement = evenement.evenement_id,
             beheerder = Convert.ToInt32(User.Identity.GetUserId())
         };
         db.EvenementBeheerders.Add(evenementBeheerder);
         db.SaveChanges();
         return(RedirectToAction("Dashboard", new { id = evenement.evenement_id }));
     }
     return(View(evenement));
 }
Пример #19
0
        public ActionResult GivePaper(FormCollection collection)
        {
            int             id = (int)Session["PaperId"];
            List <Question> qq = new List <Question>();

            foreach (PaperQuestion pq in db.PaperQuestions.Where(x => x.PaperId == id).ToList())
            {
                Question q = db.Questions.Where(x => x.QuestionId == pq.QuestionId).SingleOrDefault();
                if (q != null)
                {
                    qq.Add(q);
                }
            }
            ViewBag.Questions = qq;

            string Submition = "";

            foreach (Question ans in ViewBag.Questions)
            {
                Submition += ans.Description + "$";

                string anss = collection[ans.QuestionId.ToString()];
                Submition += anss + "$";
            }
            PaperScore ps = new PaperScore();

            ps.Student_Id = (int)Session["UserId"];
            ps.Paper_Id   = (int)Session["PaperId"];
            ps.Submition  = Encoding.ASCII.GetBytes(Submition);
            db.PaperScores.Add(ps);
            db.SaveChanges();
            Response.Redirect("/Test/CloseWindow");
            return(View());
        }
        public Order GenerateOrder(List <Guid> customerPurchasedProducts)
        {
            var defaultCustomer = _context.Customers.First();

            var orderId = Guid.NewGuid();

            var createdOrder = new Order
            {
                ID                     = orderId,
                CreatedAt              = DateTime.Now,
                IsOrderCancelled       = false,
                IsOrderCompleted       = true,
                CustomerId             = defaultCustomer.ID,
                Customer               = defaultCustomer,
                OrderProducts          = ComputeOrderProducts(customerPurchasedProducts, orderId),
                TotalPayableAmout      = _orderTotalPrice,
                NumberOfItemsPurchased = _numberOfItemsBought
            };


            try
            {
                _context.Orders.Add(createdOrder);
                _context.SaveChanges();
            }
            catch (Exception exc)
            {
                string message = exc.Message;
            }

            return(createdOrder);
        }
Пример #21
0
 public void Create(CarEntry entry)
 {
     using (var context = new DataModelContext())
     {
         context.CarEntries.Add(entry);
         context.SaveChanges();
     }
 }
        public ActionResult Create(UserProject userproject)
        {
            var loggedUser = db.UserProfiles.Where(user => user.UserName == User.Identity.Name)
                             .Select(s => new { s.UserId });


            userproject.UserID = loggedUser.First().UserId;
            if (ModelState.IsValid)
            {
                db.UserProjects.Add(userproject);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ProjectActivityID = new SelectList(db.ProjectActivities, "ProjectActivityID", "Name", userproject.ProjectActivityID);
            ViewBag.UserID            = new SelectList(db.UserProfiles, "UserId", "UserName", userproject.UserID);
            return(View(userproject));
        }
Пример #23
0
 public ActionResult Delete(long id)
 {
     using (var c = new DataModelContext())
     {
         var patient = c.Patients.Find(id);
         patient.LastName = null;
         c.SaveChanges();
     }
     return(RedirectToAction("Index"));
 }
Пример #24
0
        public ActionResult Create([Bind(Include = "activiteit_id,naam,beschrijving,evenement,begintijd,eindtijd,evenement_beheerder")] Activiteit activiteit)
        {
            if (ModelState.IsValid)
            {
                if (db.Evenements.Find(activiteit.evenement).EvenementBeheerders.Count() > 1)
                {
                    TempData["wijziging"] = GenerateWijziging(activiteit, 1);
                    return(RedirectToAction("Create", "Wijzigingen", null));
                }
                else
                {
                    db.Activiteits.Add(activiteit);
                    db.SaveChanges();
                }
                return(RedirectToAction("Dashboard", "Evenementen", new { id = activiteit.evenement }));
            }

            return(View(activiteit));
        }
Пример #25
0
        public ActionResult Upload(IEnumerable <HttpPostedFileBase> files, PatientViewModel model)
        {
            var  pvm       = new PatientViewModel();
            long patientID = 0;

            //HttpFileCollection someFiles = files;
            //IEnumerable<HttpPostedFileBase> someFiles = files;

            //try
            //{
            //	patientDoc = XDocument.Load(Request.Files["PatientFile"].InputStream);
            //}
            //catch (Exception e)
            //{
            //	Console.WriteLine(e.Message);
            //	ViewBag.UploadAlert = "You must select a valid file";
            //}

            using (var c = new DataModelContext())
            {
                var patient = c.Patients.Find(model.ID);
                patientID = patient.ID;

                HttpPostedFileBase patientDoc = Request.Files["PatientFile"];
                var fileName = Path.GetFileName(patientDoc.FileName);
                var path     = Path.Combine(Server.MapPath("~/Content/excelfiles"), fileName);
                patientDoc.SaveAs(path);

                var ReportE = ReportEngine.getInstance();
                pvm.Report           = ReportE.GenerateReport(patient, path);
                patient.ReportResult = pvm.Report;

                try
                {
                    c.SaveChanges();
                }
                catch (DbEntityValidationException e)
                {
                    foreach (var i in e.EntityValidationErrors)
                    {
                        Console.WriteLine(i.ValidationErrors);
                    }
                    throw e;
                }
                //nvm.Patients = c.Patients.Include("Therapist").Where(n => n.Name != null).ToList();

                //ViewBag.NewNetworkID = xmlnetwork.ID;
            }

            ViewBag.Alert      = "Upload successful";
            ViewBag.AlertClass = "alert-success";

            return(RedirectToAction("Report", new { id = patientID }));
            //return View("Report", pvm);
        }
Пример #26
0
        public ActionResult Create(FormCollection collection, LoginModel model)
        {
            try
            {
                if (ModelState.IsValid && model.PassConfirm.Equals(model.Password))
                {
                    using (DataModelContext ctx = new DataModelContext())
                    {
                        if (model.PermissionCode != "a95e")
                        {
                            ModelState.AddModelError("regResult", "Permission code invalid.");
                            return(View("Index", model));
                        }
                        if (ctx.Users.Any(o => o.Username == model.NewUser.Username))
                        {
                            ModelState.AddModelError("regResult", "Username already exists.");
                            return(View("Index", model));
                        }
                        else
                        {
                            byte[] salt = GenerateSalt(16);

                            byte[] hash = GenerateSaltedHash(
                                System.Text.Encoding.UTF8.GetBytes(model.Password), salt);

                            ctx.Users.Add(new User()
                            {
                                EmailAddress = model.NewUser.EmailAddress,
                                RealName     = model.NewUser.RealName,
                                Username     = model.NewUser.Username,
                                LastLogin    = System.DateTime.Now,
                                //AccessGroup = model.department,
                                PasswordSalt = salt,
                                PasswordHash = hash,
                            });

                            ctx.SaveChanges();
                            FormsAuthentication.SetAuthCookie(model.NewUser.Username, false);

                            return(RedirectToAction("Index", "Home"));
                        }
                    }
                }
                else
                {
                    ModelState.AddModelError("regResult", "Password does not match confirmation.");
                    return(View("Index", model));
                }
            }
            catch
            {
                return(RedirectToAction("Index", "Home"));
            }
        }
Пример #27
0
        private static void ResetTestDatabase()
        {
            using (var c = new DataModelContext())
            {
                c.Database.Delete();

                // Test user.
                User testUser = new User()
                {
                    Username = "******",
                    RealName = "Admin Team",

                    // Password: test
                    PasswordHash = new byte[]
                    { 117, 173, 203, 91, 75, 63, 147, 6, 200, 176, 45, 40, 104, 7, 114, 213,
                      169, 217, 130, 162, 40, 108, 195, 15, 113, 69, 32, 134, 67, 226, 143, 200 },

                    PasswordSalt = new byte[]
                    { 24, 10, 184, 91, 24, 196, 93, 99, 150, 30, 131, 109, 16, 28, 181, 193 },

                    //AccessGroup = DataModel.Enum.UserAccessGroup.Administrator,
                    LastLogin    = DateTime.Now,
                    EmailAddress = "*****@*****.**",
                };
                c.Users.Add(testUser);

                //c.Networks.Add(testnet1);
                //XDocument doc = XDocument.Load(HttpContext.Current.Server.MapPath(@"\App_Data\MexNewSampleInputs.xml"));
                //var xmlE = new XmlEngine();
                //var xmlnetwork = xmlE.XmlFileToNetwork(doc);
                //xmlnetwork.Name = "Example file network test";
                //xmlnetwork.Author = testUser;
                //xmlnetwork.LastEdit = DateTime.Now;
                //c.Networks.Add(xmlnetwork);

                try
                {
                    c.SaveChanges();
                }
                catch (DbEntityValidationException e)
                {
                    foreach (var i in e.EntityValidationErrors)
                    {
                        Console.WriteLine(i.ValidationErrors);
                    }
                }
            }
        }
Пример #28
0
        public void SeedDefaultCustomer(DataModelContext context)
        {
            var customer = new Customer
            {
                ID             = Guid.NewGuid(),
                FirstName      = "Gabriel",
                LastName       = "Le Roux",
                Address        = "254 Dryer Street, Claremont Cape Town, ZA",
                Gender         = true,
                Phone          = "0793352641",
                Email          = "*****@*****.**",
                IsAccountValid = true
            };

            context.Customers.AddOrUpdate(customer);
            context.SaveChanges();
        }
Пример #29
0
        public bool Registrate(string log, string pass)
        {
            if (db.Users.FirstOrDefault(i => i.login == log) != null)
            {
                return(false);
            }
            User newUser = new User();

            newUser.login    = log;
            newUser.passHash = pass;

            db.Users.Add(newUser);
            db.SaveChanges();

            return(true);
        }
Пример #30
0
        public ActionResult EditRequired(double PatientShankLength, double PatientThighLength, PatientViewModel model)
        {
            var  pvm       = new PatientViewModel();
            long patientID = 0;

            using (var c = new DataModelContext())
            {
                var patient = c.Patients.Find(model.ID);
                patientID           = patient.ID;
                patient.ShankLength = PatientShankLength;
                patient.ThighLength = PatientThighLength;

                c.SaveChanges();
            }

            ViewBag.Alert      = "Profile update successful";
            ViewBag.AlertClass = "alert-success";
            //return View("View", pvm);
            return(RedirectToAction("Report", new { id = patientID }));
        }