Example #1
0
        public ActionResult Create([Bind(Include = "username,password")] Admin admin)
        {
            if (ModelState.IsValid)
            {
                db.Admins.Add(admin);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(admin));
        }
        public ActionResult Create([Bind(Include = "SubcontractorID,CompanyName,subcontractorPhone,subcontractor_TypeID")] Subcontractor subcontractor)
        {
            if (ModelState.IsValid)
            {
                db.Subcontractors.Add(subcontractor);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(subcontractor));
        }
Example #3
0
        public IActionResult Create([FromBody] Widget item)
        {
            if (item == null)
            {
                return(BadRequest());
            }

            _context.Widgets.Add(item);
            _context.SaveChanges();

            return(CreatedAtRoute("GetWidget", new { id = item.Id }, item));
        }
        public ActionResult Create([Bind(Include = "ProjectID,Description,StartDate,EndDate,LocationID")] Project project)
        {
            if (ModelState.IsValid)
            {
                db.Projects.Add(project);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.LocationID = new SelectList(db.Locations, "LocationID", "Description", project.LocationID);
            return(View(project));
        }
        public ActionResult Create([Bind(Include = "LogID,HoursWorked,ProjectID,Job_TypeID,SubcontractorID")] TimeLog timeLog, string lname, string phone)
        {
            if (ModelState.IsValid)
            {
                timeLog.Clock_In    = DateTime.Now;
                timeLog.Clock_Out   = DateTime.Now;
                timeLog.HoursWorked = 8;
                timeLog.LastName    = lname;
                timeLog.PhoneNumber = phone;
                db.TimeLogs.Add(timeLog);
                db.SaveChanges();
                return(RedirectToAction("Index", "Home"));
            }

            ViewBag.Job_TypeID      = new SelectList(db.Job_Type, "Job_TypeID", "Description", timeLog.Job_TypeID);
            ViewBag.ProjectID       = new SelectList(db.Projects, "ProjectID", "Description", timeLog.ProjectID);
            ViewBag.SubcontractorID = new SelectList(db.Subcontractors, "SubcontractorID", "CompanyName", timeLog.SubcontractorID);
            return(View(timeLog));
        }
Example #6
0
        public ActionResult Create([Bind(Include = "PhoneNumber,LastName,FirstName")] TempEmployee tempEmployee)
        {
            if (ModelState.IsValid)
            {
                var currentUser = db.Database.SqlQuery <TempEmployee>("SELECT * " +
                                                                      "FROM TempEmployee " +
                                                                      "WHERE LastName LIKE '" + tempEmployee.LastName + "' AND " +
                                                                      "PhoneNumber LIKE '" + tempEmployee.PhoneNumber + "'");
                if (currentUser.Count() > 0)
                {
                    return(RedirectToAction("Create", "TimeLogs", new { lname = tempEmployee.LastName, phone = tempEmployee.PhoneNumber }));
                }
                else
                {
                    db.TempEmployees.Add(tempEmployee);
                    db.SaveChanges();
                    return(RedirectToAction("Create", "TimeLogs", new { lname = tempEmployee.LastName, phone = tempEmployee.PhoneNumber }));
                }
            }

            return(View(tempEmployee));
        }