public SpecialistPendingTeamInvitation SecondSpecialistPendingTeamInvitation()
        {
            var secondSpecialistPendingTeamInvitation = new SpecialistPendingTeamInvitation {

                 PendingTeamInvitationID = new Int32()
            ,
                 TeamId = new Int32()
            ,
                 TeamName = null,
                 MaintenanceProviderId = new Int32()
            ,
                 SpecialistID = new Int32()

             };

            return secondSpecialistPendingTeamInvitation;
        }
 public void AcceptInvitation(SpecialistPendingTeamInvitation sti)
 {
     var invitation =
         UnitofWork.SpecialistPendingTeamInvitationRepository.FirstOrDefault(
             x => x.PendingTeamInvitationID == sti.PendingTeamInvitationID);
     var mti = new MaintenanceTeamAssociation
     {
         TeamId = sti.TeamId,
         TeamName = sti.TeamName,
         MaintenanceProviderId = sti.MaintenanceProviderId,
         SpecialistId = sti.SpecialistID
     };
     UnitofWork.MaintenanceTeamAssociationRepository.Add(mti);
     UnitofWork.SpecialistPendingTeamInvitationRepository.Delete(invitation);
     AddSpecialistZoneToProviderTeamZone(sti.MaintenanceProviderId, sti.SpecialistID);
     UnitofWork.Save();
     var teamcoverageUpdate = new UpdateCoverage(sti.MaintenanceProviderId, sti.SpecialistID);
     teamcoverageUpdate.AddAllCoverageFromSpecialistToTeam();
     new JNotfiyScriptQueryHelper().JNotifyConfirmationMessage("Your request has been completed.", "/Specialist/CurrentProvider");
 }
 public ActionResult InviteTeamMember(MaintenanceTeam team)
 {
     if (Request.Params["stid"] == null || Request.Params["pid"] == null)
     {
         return RedirectToAction("AddTeamMember");
     }
     var tid = Convert.ToInt32(Request.Params["stid"]);
     var selectedteam = UnitofWork.MaintenanceTeamRepository.
         FirstOrDefault(x => x.TeamId == tid);
     var provider = UserHelper.ProviderPrivateProfileHelper.GetProvider();
     var proid = provider.MaintenanceProviderId;
     if (selectedteam != null)
     {
         var npti = new SpecialistPendingTeamInvitation
             {
                 MaintenanceProviderId = proid,
                 SpecialistID = Convert.ToInt32(Request.Params["pid"]),
                 TeamId = selectedteam.TeamId,
                 TeamName = selectedteam.TeamName
             };
         UnitofWork.SpecialistPendingTeamInvitationRepository.Add(npti);
     }
     UnitofWork.Save();
     InviteSpecialist(Convert.ToInt32(Request.Params["stid"]), Convert.ToInt32(Request.Params["pid"]));
     JNotify("Your request has been completed.", "/Provider/#team");
     return View();
 }
 public void DenyInvitation(SpecialistPendingTeamInvitation sti)
 {
     var invitation =
         UnitofWork.SpecialistPendingTeamInvitationRepository.FirstOrDefault(
             x => x.PendingTeamInvitationID == sti.PendingTeamInvitationID);
     UnitofWork.SpecialistPendingTeamInvitationRepository.Delete(invitation);
     UnitofWork.Save();
     new JNotfiyScriptQueryHelper().JNotifyConfirmationMessage("Your request has been completed.", "~/Specialist/ProviderInvitation");
 }
 public ActionResult AcceptInvitation(SpecialistPendingTeamInvitation sti)
 {
     UserHelper.SpecialistPrivateProfileHelper.AcceptInvitation(sti);
     return RedirectToAction("CurrentProvider");
 }
 public void DenyInvitation(SpecialistPendingTeamInvitation sti)
 {
     SpecialistPrivateProfileHelper.DenyInvitation(sti);
 }
 public void AcceptInvitation(SpecialistPendingTeamInvitation sti)
 {
     SpecialistPrivateProfileHelper.AcceptInvitation(sti);
 }
 public void AddNewPendingSpecialistInvitationToProviderTeam(Specialist specialist, int specialistId, int maintenanceProviderId)
 {
     var teamlist = UnitofWork.MaintenanceTeamAssociationRepository.FindBy(x => x.MaintenanceProviderId == maintenanceProviderId).ToList();
     var teamcount = UnitofWork.MaintenanceTeamAssociationRepository.Count(x => x.MaintenanceProviderId == maintenanceProviderId);
     switch (teamcount)
     {
         //if Provider has no team
         case 0:
             //UI for Creating Team and renaming and deleting Team
             //Redirect to create team
             RedirectToAction("Create", "Team");
             break;
         //If Provider has only 1 team then proceed
         case 1:
             if (ModelState.IsValid)
             {
                 var currentteam = teamlist.First();
                 var npti = new SpecialistPendingTeamInvitation
                 {
                     MaintenanceProviderId = maintenanceProviderId,
                     SpecialistID = specialistId,
                     TeamId = currentteam.TeamId,
                     TeamName = currentteam.TeamName
                 };
                 UnitofWork.SpecialistPendingTeamInvitationRepository.Add(npti);
                 UnitofWork.Save();
             }
             break;
         // Else if Provider has more than 1
         default:
             if (teamcount > 1)
             {
                 RedirectToAction("SelectTeam", "Team");
                 RedirectToAction("SelectTeam", "Team", new { id = specialistId });
             }
             break;
     }
 }