Exemple #1
0
        //[ValidateAntiForgeryToken]
        public ActionResult Create(TimesheetFormViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View("Create", viewModel));
            }
            var timesheet = new Timesheet
            {
                ArtistId = User.Identity.GetUserId(),
                StartDay = viewModel.StartTime,
                //EndDay = viewModel.EndTime
            };

            _context.Timesheets.Add(timesheet);
            _context.SaveChanges();

            return(RedirectToAction("ListView", "Timesheet"));
        }
Exemple #2
0
        public ActionResult Create(TimesheetFormViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View("Create", viewModel));
            }

            var timesheet = new Timesheet
            {
                Name     = User.Identity.Name,
                IP       = viewModel.IP,
                UserId   = User.Identity.GetUserId(),
                StartDay = viewModel.GetDateTimeStart(),
                EndDay   = viewModel.GetDateTimeEnd()
            };

            _context.Timesheets.Add(timesheet);
            _context.SaveChanges();

            return(RedirectToAction("Index", "Timesheet"));
        }
Exemple #3
0
        public ActionResult EditView([Bind(Include = /*"Id,StartDay,EndDay,UserId,Name"*/ "Id,Name,IP,StartDay,EndDay,GetDifferenceTimes()")] TimesheetFormViewModel viewModel)
        {
            var timesheet = new Timesheet
            {
                //UserId = User.Identity.GetUserId(),


                Name     = User.Identity.Name,
                IP       = viewModel.IP,
                UserId   = User.Identity.GetUserId(),
                StartDay = viewModel.GetDateTimeStart(),
                EndDay   = viewModel.GetDateTimeEnd()
            };

            if (ModelState.IsValid)
            {
                _context.Entry(timesheet).State = EntityState.Modified;
                _context.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(timesheet));
        }
Exemple #4
0
        public ActionResult EditView(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Timesheet timesheet = _context.Timesheets.Find(id);

            if (timesheet == null)
            {
                return(HttpNotFound());
            }
            TimesheetFormViewModel viewModel = new TimesheetFormViewModel
            {
                Date      = string.Format("{0} {1} {2}", timesheet.StartDay.Day, timesheet.StartDay.Month, timesheet.StartDay.Year),
                Id        = timesheet.Id,
                IP        = timesheet.IP,
                TimeStart = string.Format("{0}:{1}", timesheet.StartDay.Hour, timesheet.StartDay.Minute)
            };

            ViewBag.StartDay = viewModel.TimeStart;

            return(View(viewModel));
        }
Exemple #5
0
        public ActionResult Create()
        {
            var viewModel = new TimesheetFormViewModel();

            return(View(viewModel));
        }