Beispiel #1
0
        private void Update(int resource_id, DateTime myDate, FormCollection coll)
        {
            timedb.DeleteTimesheet(resource_id, myDate);
            List <day> myEntries = new List <day>();


            foreach (var item in coll)
            {
                if (item.ToString().Contains("r"))
                {
                    if (coll[item.ToString()] != string.Empty)
                    {
                        myEntries.Add(new day {
                            Day = int.Parse(item.ToString().Replace("r", "")), Year = myDate.Year, Month = myDate.Month, HoursWorked = decimal.Parse(coll[item.ToString()].ToString())
                        });
                    }
                }
            }
            foreach (var h in myEntries)
            {
                tbl_TimeSheet mytime = new tbl_TimeSheet();
                mytime.Resource_ID = resource_id;
                mytime.Date        = new DateTime(h.Year, h.Month, h.Day);
                mytime.Hours       = (decimal)h.HoursWorked;
                timedb.Add(mytime);
            }
            timedb.Save();
        }
        public IActionResult Create([FromRoute] string name, [FromBody] TimeBooking booking)
        {
            var timesheet = repostitory.GetByName(name);

            timesheet.BookTime(booking.Date, booking.Start, booking.Pause, booking.End);
            repostitory.Save(timesheet);

            return(CreatedAtRoute("GetByDate", new { name = name, date = booking.Date }, timesheet.GetBookingByDate(booking.Date)));
        }
        public IActionResult Create([FromBody] NewTimesheet newTimesheet)
        {
            if (repostitory.Exists(newTimesheet.Name))
            {
                return(this.ConflictWithRoute("GetByName", new { name = newTimesheet.Name }));
            }

            var timesheet = new Timesheet(newTimesheet.Name);

            repostitory.Save(timesheet);

            return(CreatedAtRoute("GetByName", new { name = timesheet.Name }, timesheet));
        }
 public IActionResult Create([FromBody] Timesheet timesheet)
 {
     Debug.WriteLine("Getting Here");
     if (timesheet == null)
     {
         return(BadRequest());
     }
     Debug.WriteLine(timesheet);
     timesheetRepository.InsertTimesheet(timesheet);
     timesheetRepository.Save();
     return(Created("GettimesheetById", timesheet));
 }
Beispiel #5
0
        public ActionResult Index(TimesheetModel timesheet)
        {
            if (!ModelState.IsValid)
            {
                return(View(timesheet));
            }

            _timesheetRepository.Save(timesheet.UserId, timesheet.Hours, timesheet.Date);
            var manager = _userRepository.GetManager(timesheet.UserId);

            if (manager != null)
            {
                _emailService.SendEmail(manager.EmailAddress);
            }

            return(RedirectToAction("Display", "Report", new { id = timesheet.UserId }));
        }