Ejemplo n.º 1
0
        private MissionToPEO FindMissionToPEOByMissionId(int missionId, string currentUsername)
        {
            List <MissionToPEOMapping> missionToPEOMappings = FindAll(currentUsername);
            MissionToPEO missionToPEO = new MissionToPEO();

            if (missionToPEOMappings != null)
            {
                try
                {
                    missionToPEOMappings     = missionToPEOMappings.FindAll(MissionToPEOMapping => MissionToPEOMapping.Mission.Id == missionId);
                    missionToPEO.Mission     = (missionToPEOMappings.Count > 0) ? missionToPEOMappings[0].Mission : null;
                    missionToPEO.MapPEOLists = new List <MapPEO>();

                    foreach (var items in missionToPEOMappings)
                    {
                        MapPEO mapPEO = new MapPEO()
                        {
                            PEO    = items.PEO,
                            Points = items.Points
                        };
                        missionToPEO.MapPEOLists.Add(mapPEO);
                    }
                }
                catch (Exception ex)
                {
                    Logger.Log(ex);
                }
            }
            return(missionToPEO);
        }
Ejemplo n.º 2
0
        internal string SaveMapping(MissionToPEO missionToPEO, string name)
        {
            try
            {
                missionToPEO.Mission = MissionService.FindById(missionToPEO.Mission.Id, name);

                if (missionToPEO.MapPEOLists.Count > 0)
                {
                    foreach (var item in missionToPEO.MapPEOLists)
                    {
                        MissionToPEOMapping missionToPEOMapping = new MissionToPEOMapping()
                        {
                            Mission = missionToPEO.Mission,
                            PEO     = PEOService.FindById(item.PEO.Id, name),
                            Points  = item.Points
                        };
                        if (!IsExistMapping(missionToPEOMapping, name))
                        {
                            Save(missionToPEOMapping, name);
                        }
                    }
                    return(null);
                }
                else
                {
                    return(Messages.InvalidField);
                }
            }
            catch (Exception ex)
            {
                Logger.Log(ex);
                return(ex.Message);
            }
        }
 public ActionResult MissionToPEOEdit(int id)
 {
     if (id > 0)
     {
         MissionToPEO MissionToPEO = MissionToPEOMappingService.FindByMissionId(id, User.Identity.Name);
         return(View(MissionToPEO));
     }
     return(View());
 }
 /// --------------------- MISSION TO PEO ------------------------------///
 public ActionResult MissionToPEODetails(int id)
 {
     if (id > 0)
     {
         MissionToPEO MissionToPEOMapping = MissionToPEOMappingService.FindByMissionId(id, User.Identity.Name);
         return(PartialView("Partial/MissionToPEODetails", MissionToPEOMapping));
     }
     return(View());
 }
Ejemplo n.º 5
0
 internal string UpdateMapping(MissionToPEO missionToPEO, string name)
 {
     try
     {
         if (missionToPEO.MapPEOLists.Count > 0)
         {
             missionToPEO.Mission = MissionService.FindById(missionToPEO.Mission.Id, name);
             if (missionToPEO != null)
             {
                 foreach (var item in missionToPEO.MapPEOLists)
                 {
                     MissionToPEOMapping missionToPEOMapping = new MissionToPEOMapping()
                     {
                         Mission = missionToPEO.Mission,
                         PEO     = PEOService.FindById(item.PEO.Id, name),
                         Points  = item.Points
                     };
                     if (!IsExistMapping(missionToPEOMapping, name))
                     {
                         Save(missionToPEOMapping, name);
                     }
                     else
                     {
                         var deleteorUpdate = FindAll(name).Find(mp => mp.Mission.Id == missionToPEOMapping.Mission.Id && mp.PEO.Id == missionToPEOMapping.PEO.Id);
                         missionToPEOMapping.Id = deleteorUpdate.Id;
                         Update(missionToPEOMapping, name);
                     }
                 }
                 return(null);
             }
             else
             {
                 return(Messages.MissionNotFound);
             }
         }
         else
         {
             return(Messages.InvalidField);
         }
     }
     catch (Exception ex)
     {
         Logger.Log(ex);
         return(ex.Message);
     }
 }
 public ActionResult MissionToPEOCreate(MissionToPEO MissionToPEO)
 {
     if (ModelState.IsValid)
     {
         string message = MissionToPEOMappingService.SaveMapping(MissionToPEO, User.Identity.Name);
         if (string.IsNullOrEmpty(message))
         {
             TempData["Success"] = Messages.Created;
             return(RedirectToAction("Index"));
         }
         else
         {
             ViewData["Warning"] = message;
         }
     }
     else
     {
         ViewData["Error"] = Messages.InvalidField;
     }
     return(View());
 }
Ejemplo n.º 7
0
        public MissionToPEO FindByMissionId(int id, string CurrentUsername)
        {
            MissionToPEO FoundedMissionToPEO = FindMissionToPEOByMissionId(id, CurrentUsername);

            return(FoundedMissionToPEO);
        }