Beispiel #1
0
        public ActionResult ShowResponsable(decimal id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            SearchResponsableViewModel sr = new SearchResponsableViewModel();

            sr.organisme   = db.Organismes.Find(id);
            sr.OrganismeId = id;

            // Tempdata use when delete on responsable is called
            TempData["organisme"] = sr.organisme.Id;
            return(View(sr));
        }
Beispiel #2
0
        public ActionResult ShowResponsable(SearchResponsableViewModel sr)
        {
            Organismes org = db.Organismes.Find(sr.OrganismeId);

            sr.organisme = org;

            ResponsableOrgaViewModel Ro = new ResponsableOrgaViewModel();

            Ro.responsable.Licence = sr.NumeroLicence;

            // Tempdata use when delete on responsable is called
            TempData["organisme"] = org.Id;

            if (ModelState.IsValid)
            {
                if (!org.Responsable.Any(r => r.Licence == sr.NumeroLicence))
                {
                    if (db.Responsable.Any(r => r.Licence == sr.NumeroLicence))
                    {
                        Ro.responsable = db.Responsable.Where(r => r.Licence == sr.NumeroLicence).First();;
                    }
                    else if (IsExistInWebService(Ro.responsable))
                    {
                    }
                    else
                    {
                        ModelState.AddModelError("NumeroLicence", "La personne avec le numéro de licence " + sr.NumeroLicence + " n'existe pas ou est déjà présente pour cette organisme.");
                        return(View(sr));
                    }
                    Ro.OrganismeId          = sr.OrganismeId;
                    TempData["responsable"] = Ro;
                    return(RedirectToAction("AddResponsable"));
                }
                else
                {
                    ModelState.AddModelError("NumeroLicence", "La personne avec le numéro de licence " + sr.NumeroLicence + " n'existe pas ou est déjà présente pour cette organisme.");
                    return(View(sr));
                }
            }
            return(View(sr));
        }