public ActionResult Create([Bind(Include = "EmployeeTimeID,CapturedDate,ChargableTime,ProjectCode,ProjectOwner,Client,EmployeeID,TotalBillableHours,OverTimeHours,Comments")] EmployeeTime employeeTime)
        {
            var employeeModel = db.Employees
                                .Where(c => c.EmployeeID == employeeTime.EmployeeID)
                                .SingleOrDefault();

            if (ModelState.IsValid)
            {
                var capture = new EmployeeTime
                {
                    EmployeeID         = employeeTime.EmployeeID,
                    CapturedDate       = employeeTime.CapturedDate,
                    TotalBillableHours = employeeTime.TotalBillableHours,
                    ChargableTime      = employeeTime.ChargableTime,
                    ProjectCode        = employeeTime.ProjectCode,
                    ProjectOwner       = employeeTime.ProjectOwner,
                    Comments           = employeeTime.Comments,
                    Client             = employeeTime.Client //,
                                                             // OverTimeHours = employeeTime.OverTimeHours,
                };
                // employeeTime.EmployeeTimeID = Guid.NewGuid();
                db.EmployeeTimes.Add(capture);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            //ViewBag.EmployeeID = new SelectList(db.Employees, "EmployeeID", "LastName", employeeTime.EmployeeID);
            return(View(employeeTime));
        }
        public ActionResult CaptureTime([Bind(Include = "EmployeeTimeID,EmployeeID,CapturedDate,TotalBillableHours,ChargableTime,ProjectCode,ProjectOwner,Comments,Client")] CaptureViewModel model)
        {
            var EmployeeModel = db.Employees
                                .Where(c => c.EmployeeID == model.EmployeeId)
                                .SingleOrDefault();

            if (ModelState.IsValid)
            {
                var capture = new EmployeeTime
                {
                    EmployeeID         = model.EmployeeId,
                    CapturedDate       = model.CapturedDate,
                    TotalBillableHours = model.TotalBillableHours,
                    ChargableTime      = model.ChargeableTime,
                    ProjectCode        = model.ProjectCode,
                    ProjectOwner       = model.ProjectOwner,
                    Comments           = model.Comments,
                    Client             = model.Client,
                    // EmployeeTimeID = model.EmployeeTimeID
                };
                db.EmployeeTimes.Add(capture);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(RedirectToAction("Index"));
        }
Example #3
0
        public async Task <ActionResult <EmployeeTime> > PostEmployeeTime(EmployeeTime employeeTime)
        {
            _context.EmployeeTime.Add(employeeTime);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetEmployeeTime", new { id = employeeTime.PK_EmployeeTime }, employeeTime));
        }
Example #4
0
        public async Task <IActionResult> PutEmployeeTime(int id, EmployeeTime employeeTime)
        {
            if (id != employeeTime.PK_EmployeeTime)
            {
                return(BadRequest());
            }

            _context.Entry(employeeTime).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!EmployeeTimeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public ActionResult DeleteConfirmed(Guid id)
        {
            EmployeeTime employeeTime = db.EmployeeTimes.Find(id);

            db.EmployeeTimes.Remove(employeeTime);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "EmployeeTimeID,CapturedDate,ChargableTime,ProjectCode,ProjectOwner,Client,EmployeeID,TotalBillableHours,Comments")] EmployeeTime employeeTime)
 {
     if (ModelState.IsValid)
     {
         db.Entry(employeeTime).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.EmployeeID = new SelectList(db.Employees, "EmployeeID", "LastName", employeeTime.EmployeeID);
     return(View(employeeTime));
 }
 public ActionResult Edit([Bind(Include = "EmpTimeID,EmpDate,EmpClockIn,EmpClockOut,EmpID,Present")] EmployeeTime employeeTime)
 {
     if (ModelState.IsValid)
     {
         db.Entry(employeeTime).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.EmpID = new SelectList(db.Employees, "EmpID", "FirstName", employeeTime.EmpID);
     return(View(employeeTime));
 }
        // GET: EmployeeTimes/Details/5
        public ActionResult Details(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            EmployeeTime employeeTime = db.EmployeeTimes.Find(id);

            if (employeeTime == null)
            {
                return(HttpNotFound());
            }
            return(View(employeeTime));
        }
        // GET: EmployeeTimes/Edit/5
        public ActionResult Edit(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            EmployeeTime employeeTime = db.EmployeeTimes.Find(id);

            if (employeeTime == null)
            {
                return(HttpNotFound());
            }
            ViewBag.EmployeeID = new SelectList(db.Employees, "EmployeeID", "LastName", employeeTime.EmployeeID);
            return(View(employeeTime));
        }