public static TimeSheetMaster CreateTimeSheetMasterTemplate(DateTime forCalendarMonth, Staff staff)
        {
            TimeSheetMaster master = new TimeSheetMaster();

            master.PersonId   = staff.PersonId;
            master.Person     = staff;
            master.Company    = staff.Supervisor.Company;
            master.Supervisor = staff.Supervisor;
            master.AgencyId   = staff.AgentId;
            master.Month      = forCalendarMonth.Month;
            master.Year       = forCalendarMonth.Year;

            List <TimeSheetDetail> listDetails = new List <TimeSheetDetail>();

            for (int i = 1; i <= DateTime.DaysInMonth(forCalendarMonth.Year, forCalendarMonth.Month); i++)
            {
                TimeSheetDetail detail = new TimeSheetDetail();
                detail.StartTime = new DateTime(forCalendarMonth.Year, forCalendarMonth.Month, i);
                detail.EndTime   = new DateTime(forCalendarMonth.Year, forCalendarMonth.Month, i);
                listDetails.Add(detail);
            }
            master.TimeSheetDetail = listDetails;

            return(master);
        }
Exemplo n.º 2
0
        //
        // GET: /TimeSheet/Delete/5

        public ActionResult Delete(int id = 0)
        {
            TimeSheetDetail detail = TimesheetRepository.GetTimeSheetDetailById(id);

            if (detail == null)
            {
                return(HttpNotFound());
            }
            return(View(detail));
        }
 public async Task <IActionResult> Update([FromBody] TimeSheetDetail timeSheetDetail)
 {
     try
     {
         _context.Entry(timeSheetDetail).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
         _context.SaveChanges();
         return(Ok(timeSheetDetail));
     }
     catch (Exception e)
     {
         return(BadRequest(e));
     }
 }
 public async Task <IActionResult> Create([FromBody] TimeSheetDetail timeSheetDetail)
 {
     try
     {
         _context.TimeSheetDetails.Add(timeSheetDetail);
         _context.SaveChanges();
         return(Ok(timeSheetDetail));
     }
     catch (Exception e)
     {
         return(BadRequest(e));
     }
 }
 public bool InsertTimeSheetDetail(int TimeSheetID, int Bonus, int Penalty, string Currency, string Desc)
 {
     try
     {
         TimeSheetDetail tsDetail = new TimeSheetDetail();
         tsDetail.TimeSheetID = TimeSheetID;
         tsDetail.Bonus       = Bonus;
         tsDetail.Penalty     = Penalty;
         tsDetail.Desc        = Desc;
         tsDetail.Currency    = Currency;
         context.TimeSheetDetails.InsertOnSubmit(tsDetail);
         context.SubmitChanges();
         return(true);
     }
     catch (Exception e)
     {
         throw new Exception("Error Insert TimeSheetDetail: " + e.Message);
     }
 }
Exemplo n.º 6
0
 public ActionResult DeleteConfirmed(int id)
 {
     TimeSheetDetail.Delete(id);
     return(RedirectToAction("Index"));
 }
Exemplo n.º 7
0
        public IActionResult CreateTimeSheetDetail(IFormCollection inFormData)
        {
            string customMessage = "";
            object result        = null;

            string email      = _userManager.GetUserName(User);
            int    userInfoId = Database.UserInfo.Single(input => input.Email == email).UserInfoId;
            string fullname   = Database.UserInfo.Single(input => input.Email == email).FullName;

            //int userInfold = Database.UserInfo.Single(input => input.LoginUserName == userLoginName).UserInfoId;
            //string userLoginName = Database.UserInfo.Where(input => input.LoginUserName == userLoginName);


            // DateTime lessonDate = "";

            //DateTime date = DateTime.ParseExact(inFormData["dateOfLesson"], ");

            // Declare a DateTime Variable and get the informData's dateOfLesson into it
            string time = inFormData["officialTimeIn"];
            //string lessonDate = inFormData["dateOfLesson"];
            DateTime LessonDate = DateTime.ParseExact(inFormData["dateOfLesson"], "d/M/yyyy", CultureInfo.InvariantCulture);
            // Concate the 1 with the month and year in date of lesson
            string GetMonthAndYear = string.Format("1/{0}/{1}", LessonDate.Month, LessonDate.Year);
            //
            DateTime MonthYear   = DateTime.ParseExact(GetMonthAndYear, "d/M/yyyy", CultureInfo.InvariantCulture);
            int      timeSheetId = Database.TimeSheets.Single(input => input.CreatedById == userInfoId && input.MonthAndYear == MonthYear).TimeSheetId;


            TimeSheetDetail oneNewTimeSheetDetail = new TimeSheetDetail();

            var accountNameSelected = inFormData["accountName"];

            var currentDateTime = DateTime.Now;

            var ar = Database.AccountRates
                     .Where(input => input.EffectiveStartDate <= currentDateTime)
                     .ToList();


            //var ratePerHourFromAccountName = Database.AccountRates
            //                                 .Include(input => input.CustomerAccount)
            //                                 .Where(input => input.CustomerAccount.AccountName == accountNameSelected)
            //                                 && ();

            //var rateWithAccountName = Database.CustomerAccounts
            //                            .Include(input=>input.AccountRates)
            //                            .Where(input=>input.AccountName==accountNameSelected)



            var ss   = inFormData["sessionSynopsisNames"];
            var test = "";

            try
            {
                oneNewTimeSheetDetail.TimeSheetId = timeSheetId;//oneNewTimeSheetDetail .TimeSheet.TimeSheetId
                //oneNewTimeSheetDetail.TimeSheetId = 12;

                oneNewTimeSheetDetail.AccountName            = inFormData["accountName"];
                oneNewTimeSheetDetail.OfficialTimeInMinutes  = ConvertHHMMToMinutes(inFormData["officialTimeIn"]);
                oneNewTimeSheetDetail.OfficialTimeOutMinutes = ConvertHHMMToMinutes(inFormData["officialTimeOut"]);
                oneNewTimeSheetDetail.WageRatePerHour        = 0;
                //Decimal.Parse(inFormData["wageRate"]);
                oneNewTimeSheetDetail.RatePerHour = 0;
                //Decimal.Parse(inFormData["ratePerHour"]);
                oneNewTimeSheetDetail.DateOfLesson = DateTime.ParseExact(inFormData["dateOfLesson"], "d/M/yyyy", CultureInfo.InvariantCulture);

                //oneNewTimeSheetDetail.TimeInInMinutes = ConvertHHMMToMinutes(inFormData["timeIn"]);
                //oneNewTimeSheetDetail.TimeOutInMinutes = ConvertHHMMToMinutes(inFormData["timeOut"]);
                //oneNewTimeSheetDetail.Comments = inFormData["comments"];

                oneNewTimeSheetDetail.SessionSynopsisNames    = inFormData["sessionSynopsisNames"];
                oneNewTimeSheetDetail.IsReplacementInstructor = bool.Parse(inFormData["isReplacementInstructor"]);
                test = ss;

                //oneNewTimeSheetDetail.CreatedAt = DateTime.Now;
                //oneNewTimeSheetDetail.UpdatedAt = DateTime.Now;
                oneNewTimeSheetDetail.CreatedByName = fullname;
                oneNewTimeSheetDetail.UpdatedByName = fullname;
                Database.TimeSheetDetails.Add(oneNewTimeSheetDetail);
                Database.SaveChanges();
            }
            catch (Exception ex)

            {
                //String innerMessage = (ex.InnerException != null)
                //    ? ex.InnerException.Message
                //    : "";
                if (ex.InnerException.Message != null)
                {
                    String innerMessage = ex.InnerException.Message;

                    object httpFailRequestResultMessage = new { message = innerMessage };
                    //Return a bad http request message to the client
                    return(BadRequest(httpFailRequestResultMessage));

                    //customMessage += "Unable to save Timesheet detail Record.";
                    //object httpFailRequestResultMessage = new { message = customMessage};
                    ////Return a bad http request message to the client
                    //return BadRequest(httpFailRequestResultMessage);
                }
            }

            //Message member variable (property)
            var successRequestResultMessage = new
            {
                message = "Saved timesheet detail record"
            };

            OkObjectResult httpOkResult =
                new OkObjectResult(successRequestResultMessage);

            return(httpOkResult);
        }
 public static IEnumerable <TimeSheetDetail> GetAllTimeSheetDetails()
 {
     return(TimeSheetDetail.GetAll());
 }
        //----------------------------------------------------------------------------------

        public static TimeSheetDetail GetTimeSheetDetailById(int TimeSheetDetailId)
        {
            return(TimeSheetDetail.GetById(TimeSheetDetailId));
        }