Example #1
0
        public ActionResult Create()
        {
            string  data   = GetDataFromBody();
            AllItem result = JsonConvert.DeserializeObject <AllItem>(data);

            _context.AllItems.Add(result);
            _context.SaveChanges();
            return(CreatedAtRoute("GetTodo", new { id = result.Id }, result));
        }
        public ActionResult Create([Bind(Include = "ShipId,Name,Manufacturer,Role,ProductionState,CargoCapacity,MaxCrew,MinCrew,SCMSpeed,ABSpeed")] Ship ship)
        {
            if (ModelState.IsValid)
            {
                db.Ships.Add(ship);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(ship));
        }
Example #3
0
        public ActionResult Create([Bind(Include = "userId,orgId,username,handle,email,pwd,admin")] User user)
        {
            if (ModelState.IsValid)
            {
                db.Users.Add(user);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(user));
        }
Example #4
0
        public ActionResult Create([Bind(Include = "Id,Name,PhoneNo,College,Password,Username,Role")] Orderer orderer)
        {
            if (ModelState.IsValid)
            {
                db.Orderers.Add(orderer);
                db.SaveChanges();
                return(RedirectToAction("Login", "AuthAuth"));
            }

            return(View(orderer));
        }
Example #5
0
        public ActionResult Create(Movie movie)
        {
            if (ModelState.IsValid)
            {
                db.Movies.Add(movie);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(movie));
        }
Example #6
0

        
        public ActionResult AddToOrg(int?id)
        {
            User user = db.Users.Find(id);

            if (Session["LoggedIn"] != null)
            {
                User lg = (User)Session["loggedIn"];
                user.orgId = lg.orgId;
            }

            db.Entry(user).State = EntityState.Modified;
            db.SaveChanges();
            return(RedirectToAction("Organizations"));
        }
        public IActionResult AddProduct(Products product)
        {
            if (ModelState.IsValid)
            {
                dbContext.products.Add(product);
                dbContext.SaveChanges();
                return(RedirectToAction("Index"));
            }
            //rendering on a Post method to preserve model state, Keeping ViewBag Constant.
            List <Products> AllProducts = dbContext.products.ToList();

            ViewBag.Products = AllProducts;
            return(View("Index", product));
        }
Example #9
0
        public ActionResult Create([Bind(Include = "Id,Item,Price,Pic,description")] Choice choice, HttpPostedFileBase file)
        {
            if (ModelState.IsValid)
            {
                file.SaveAs(HttpContext.Server.MapPath("~/images/choices/")
                            + file.FileName);
                choice.Pic = file.FileName;
                db.Choices.Add(choice);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(choice));
        }
        public ActionResult EditReporte(int?Id)
        {
            if (Id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            using (var db = new AllContext())
            {
                var reporteUpdate = db.Reportes.Find(Id);
                if (TryUpdateModel(reporteUpdate, "",
                                   new string[] { "GastosTransportes", "GastosTransporteAereos", "GastosAlimenticios", "GastosHotelarios", "GastosImprevistos" }))
                {
                    try
                    {
                        db.SaveChanges();

                        return(RedirectToAction("Index"));
                    }
                    catch (RetryLimitExceededException /* dex */)
                    {
                        ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists, see your system administrator.");
                    }
                }
                return(View(reporteUpdate));
            }
        }
        public ActionResult Create([Bind(Include = "orgId,username,handle,email,pwd,retype,admin")]  ViewModels.Home.RegisterViewModel user)
        {
            var isValidName  = false;
            var isValidEmail = false;
            var newName      = db.Users.Where(p => p.username == user.username);
            var newEmail     = db.Users.Where(p => p.email == user.email);

            if (newName.Any())
            {
                ModelState.AddModelError("username", "That name is taken");
            }
            else
            {
                isValidName = true;
            }
            if (newEmail.Any())
            {
                ModelState.AddModelError("email", "There is already an account for that email");
            }
            else
            {
                isValidEmail = true;
            }

            if (ModelState.IsValid && isValidName && isValidEmail)
            {
                User validUser = new Models.User();

                //TODO: determine what is up with discriminator
                validUser.orgId    = user.orgId;
                validUser.username = user.username;
                validUser.userId   = user.userId;
                validUser.handle   = user.handle;
                validUser.email    = user.email;
                validUser.pwd      = user.pwd;
                validUser.admin    = user.admin;

                //User validUser = user as User;
                db.Users.Add(validUser);
                db.SaveChanges();
                return(RedirectToAction("login", "Users"));
            }

            ViewBag.orgs = new SelectList(db.Orgs, "OrgId", "Name");
            return(View(user));
        }
Example #12
0
        public void addNew(Muvelet _Muvelet)
        {
            using (var ctx = new AllContext(serverName, baseName, userName, password))
            {
                ctx.Muvelets.Add(_Muvelet);

                ctx.SaveChanges();
            }
        }
Example #13
0
        public void addNew(EljarasTipus _EljarasTipus)
        {
            using (var ctx = new AllContext(serverName, baseName, userName, password))
            {
                ctx.EljarasTipuss.Add(_EljarasTipus);

                ctx.SaveChanges();
            }
        }
        public void addNew(Ac4yIdentification _Ac4yIdentification)
        {
            using (var ctx = new AllContext(baseName))
            {
                ctx.Ac4yIdentifications.Add(_Ac4yIdentification);

                ctx.SaveChanges();
            }
        }
        public void addNew(Modul _Modul)
        {
            using (var ctx = new AllContext(serverName, baseName, userName, password))
            {
                ctx.Moduls.Add(_Modul);

                ctx.SaveChanges();
            }
        }
        public void addNew(RAMetaObjektum _RAMetaObjektum)
        {
            using (var ctx = new AllContext(serverName, baseName, userName, password))
            {
                ctx.RAMetaObjektums.Add(_RAMetaObjektum);

                ctx.SaveChanges();
            }
        }
Example #17
0
        public void addNew(TaroltEljaras _TaroltEljaras)
        {
            using (var ctx = new AllContext(serverName, baseName, userName, password))
            {
                ctx.TaroltEljarass.Add(_TaroltEljaras);

                ctx.SaveChanges();
            }
        }
Example #18
0
        public void addNew(Kepernyo _Kepernyo)
        {
            using (var ctx = new AllContext(serverName, baseName, userName, password))
            {
                ctx.Kepernyos.Add(_Kepernyo);

                ctx.SaveChanges();
            }
        }
        public void addNew(Ac4yXMLObject _Ac4yXMLObject)
        {
            using (var ctx = new AllContext(serverName, baseName, userName, password))
            {
                ctx.Ac4yXMLObjects.Add(_Ac4yXMLObject);

                ctx.SaveChanges();
            }
        }
        public void addNew(TablaOszlop _TablaOszlop)
        {
            using (var ctx = new AllContext(serverName, baseName, userName, password))
            {
                ctx.TablaOszlops.Add(_TablaOszlop);

                ctx.SaveChanges();
            }
        }
Example #21
0
        public void addNew(Ac4ySDSequence _Ac4ySDSequence)
        {
            using (var ctx = new AllContext(baseName, userName, password))
            {
                ctx.Ac4ySDSequences.Add(_Ac4ySDSequence);

                ctx.SaveChanges();
            }
        }
Example #22
0
        public void addNew(Ac4y _Ac4y)
        {
            using (var ctx = new AllContext(baseName))
            {
                ctx.Ac4ys.Add(_Ac4y);

                ctx.SaveChanges();
            }
        }
 public IActionResult AddChef(Chef newChef)
 {
     if (ModelState.IsValid)
     {
         // take the userReg object and convert it to User, with a hashed pw
         Chef newerChef = new Chef
         {
             firstname  = newChef.firstname,
             lastname   = newChef.lastname,
             dob        = newChef.dob,
             created_at = DateTime.Now,
             updated_at = DateTime.Now,
         };
         // save the new user with hashed pw
         dbContext.chef.Add(newerChef);
         dbContext.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View("newChef", newChef));
 }
Example #24
0
        public ActionResult Create([Bind(Include = "OrgId,Name,Members,Focus")] Org org)
        {
            if (ModelState.IsValid)
            {
                db.Orgs.Add(org);
                db.SaveChanges();

                User user = (User)Session["loggedIn"];
                user.orgId          = org.OrgId;
                user.admin          = true;
                Session["loggedId"] = user;

                db.Entry(user).State = EntityState.Modified;
                db.SaveChanges();

                //TODO: unique org names

                return(RedirectToAction("Organizations", "Organizations"));
            }

            return(View(org));
        }
        public ActionResult DeleteReporte(int?Id)
        {
            using (var db = new AllContext())
            {
                var query = (from p in db.Reportes
                             where p.ReporteId == Id
                             select p).Single();

                db.Reportes.Remove(query);
                db.SaveChanges();
            }
            return(RedirectToAction("Index"));
        }
Example #26
0
        public IHttpActionResult GetRestriction(string oc)
        {
            Restriction restriction = db.Oc.Find(1);

            if (restriction == null)
            {
                return(NotFound());
            }
            if (oc.Equals("open"))
            {
                restriction.Oc = "open";
            }
            else
            {
                restriction.Oc = "close";
            }

            db.Entry(restriction).State = EntityState.Modified;

            db.SaveChanges();

            return(Ok(restriction));
        }
Example #27
0
        public ActionResult Add()
        {
            List <string> both = new List <string>();
            List <string> name = new List <string>();
            List <int>    id   = new List <int>();

            var today = DateTime.Today;
            var v     = (from s in db.Menus
                         where DbFunctions.TruncateTime(s.Date) == today
                         select s).FirstOrDefault();

            if (v == null)
            {
                Menu n = new Menu(DateTime.Now);
                db.Menus.Add(n);
                db.SaveChanges();
            }

            var k = (from s in db.Menus
                     where DbFunctions.TruncateTime(s.Date) == today
                     select s).FirstOrDefault();

            {
                both = Request.QueryString.ToString().Split('&').ToList();
                foreach (var m in both)
                {
                    string comp = m.Split('=')[0];

                    var t = db.Choices.Where(x => x.Item == comp).Select(x => x.Id);
                    int i = t.First();

                    db.MenuChoices.Add(new MenuChoice(k.Id, i));
                    db.SaveChanges();
                }
            }
            return(Redirect("Index"));
        }
Example #28
0
        public AllController(AllContext context)
        {
            _context = context;

            if (_context.AllItems.Any())
            {
                _context.AllItems.Add(new AllItem {
                    Name = "Item1"
                });
                _context.AllItems.Add(new AllItem {
                    Name = "Item2"
                });
                _context.SaveChanges();
            }
        }
Example #29
0
        public ApibeController(AllContext context)
        {
            _context = context;

            if (_context.Discos.Count() == 0)
            {
                DayOfWeek dia = DateTime.Now.DayOfWeek;


                _context.Discos.Add(new Disco {
                    Nome = "teste"
                });
                _context.Discos.Add(new Disco {
                    Nome = "Disco2"
                });
                _context.SaveChanges();
            }
        }
 public ActionResult Create([Bind(Include = "GastosTransportes,GastosTransporteAereos,GastosAlimenticios,GastosHotelarios,GastosImprevistos")] Reporte reporte)
 {
     try
     {
         using (var db = new AllContext())
         {
             if (ModelState.IsValid)
             {
                 db.Reportes.Add(reporte);
                 db.SaveChanges();
                 return(RedirectToAction("Index"));
             }
         }
     }
     catch (RetryLimitExceededException /* dex */)
     {
         ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists, see your system administrator.");
     }
     return(View(reporte));
 }