private void SaveEditRosterEntries(List<RosterAttributes> rosters, int _RotaAppID)
        {
            RosterApp rotaApp = db.RosterApps.First(aa=>aa.RotaApplD==_RotaAppID);
            Shift shift = db.Shifts.First(aa => aa.ShiftID == rotaApp.ShiftID);

            foreach (var roster in rosters)
            {
                if (isRosterValueChanged(roster, shift))
                {
                    RosterDetail rosterDetail = new RosterDetail() ;
                    rosterDetail.CriteriaValueDate = rotaApp.RosterCriteria.ToString() + rotaApp.CriteriaData.ToString() + roster.DutyDate.ToString("yyMMdd");
                    rosterDetail.CompanyID = rotaApp.CompanyID;
                    rosterDetail.OpenShift = shift.OpenShift;
                    rosterDetail.UserID = rotaApp.UserID;
                    rosterDetail.RosterAppID = _RotaAppID;
                    if (roster.WorkMin == 0)
                    {
                        rosterDetail.DutyCode = "R";
                    }
                    else
                    {
                        rosterDetail.DutyCode = "D";
                    }
                    if (roster.DutyTime == new TimeSpan(0, 0, 0))
                    {
                        rosterDetail.OpenShift = true;
                    }
                    else
                    {
                        rosterDetail.OpenShift = false;
                    }
                    rosterDetail.DutyTime = roster.DutyTime;
                    rosterDetail.WorkMin = (short)roster.WorkMin;
                    rosterDetail.RosterDate = roster.DutyDate;
                        db.RosterDetails.Add(rosterDetail);
                    db.SaveChanges();
                }
            }
        }
 private void CreateRosterEntries(Shift _selectedShift, string criteria, int criteriaValue, DateTime startDate, int noOfDays, List<RosterAttributes> rosters, int _RotaAppID)
 {
     int _userID = Convert.ToInt32(Session["LogedUserID"].ToString());
     foreach (var roster in rosters)
     {
         if (isRosterValueChanged(roster, _selectedShift))
         {
             RosterDetail _RotaDetail = new RosterDetail();
             _RotaDetail.CriteriaValueDate = criteria.ToString() + criteriaValue.ToString() + roster.DutyDate.ToString("yyMMdd");
             _RotaDetail.CompanyID = _selectedShift.CompanyID;
             _RotaDetail.OpenShift = _selectedShift.OpenShift;
             _RotaDetail.UserID = _userID;
             _RotaDetail.RosterAppID = _RotaAppID;
             if (roster.WorkMin == 0)
             {
                 _RotaDetail.DutyCode = "R";
             }
             else
             {
                 _RotaDetail.DutyCode = "D";
             }
             if (roster.DutyTime == new TimeSpan(0, 0, 0))
             {
                 _RotaDetail.OpenShift = true;
             }
             else
             {
                 _RotaDetail.OpenShift = false;
             }
             _RotaDetail.DutyTime = roster.DutyTime;
             _RotaDetail.WorkMin = (short)roster.WorkMin;
             _RotaDetail.RosterDate = roster.DutyDate;
             db.RosterDetails.Add(_RotaDetail);
             db.SaveChanges();
         }
     }
 }