Exemplo n.º 1
0
 public ActionResult Respond(InterestedModel interestedModel, string id)
 {
     if (Request["user"] == "" || Request["pno"] == "" || Request["occupation"] == "" || Request["fmembers"] == "" || Request["fmembers"] == "" || Request["paddress"] == "")
     {
         ModelState.AddModelError(String.Empty, "One or more Empty fields");
         InterestedModel interestedModel123 = interestedRep.get1Respond(id, User.Identity.Name);
         if (interestedModel123 == null)
         {
             InterestedModel i = new InterestedModel()
             {
                 ad_id          = id,
                 familymembers  = "",
                 name           = "",
                 occupation     = "",
                 phone          = "",
                 presentAddress = "",
                 users_id       = "",
             };
             return(View(i));
         }
         return(View(interestedModel123));
     }
     else
     {
         InterestedModel interestedModel1 = new InterestedModel()
         {
             users_id       = User.Identity.Name,
             ad_id          = id,
             name           = Request["user"],
             phone          = Request["pno"],
             occupation     = Request["occupation"],
             familymembers  = Request["fmembers"],
             presentAddress = Request["paddress"]
         };
         if (ModelState.IsValid)
         {
             if (interestedRep.chkRespond(id, User.Identity.Name))
             {
                 interestedRep.updateRespond(interestedModel1);
             }
             else
             {
                 interestedRep.addRespond(interestedModel1);
             }
         }
         InterestedModel interestedModel12 = interestedRep.get1Respond(id, User.Identity.Name);
         return(View(interestedModel12));
     }
 }
Exemplo n.º 2
0
 public void addRespond(InterestedModel interestedModel)
 {
     using (var context = new toletBDdbEntities1())
     {
        Interested users = new Interested()
         {
             users_id=interestedModel.users_id,
             name=interestedModel.name,
             ad_id=interestedModel.ad_id,
             phone=interestedModel.phone,
             occupation=interestedModel.occupation,
             familymembers=interestedModel.familymembers,
             presentAddress=interestedModel.presentAddress
         };
         context.Interesteds.Add(users);
         context.SaveChanges();
     }
 }
Exemplo n.º 3
0
        public bool updateRespond(InterestedModel interestedModel)
        {
            using (var context = new toletBDdbEntities1())
            {
                var ad = context.Interesteds.FirstOrDefault(x => x.ad_id == interestedModel.ad_id);
                if (ad != null)
                {
                    ad.name = interestedModel.name;
                    ad.phone = interestedModel.phone;
                    ad.occupation = interestedModel.occupation;
                    ad.familymembers = interestedModel.familymembers;
                    ad.presentAddress = interestedModel.presentAddress;

                }

                context.SaveChanges();
                return true;
            }
        }
Exemplo n.º 4
0
        public ActionResult Respond(string id)
        {
            string          s = User.Identity.Name;
            InterestedModel interestedModel = interestedRep.get1Respond(id, s);

            if (interestedModel == null)
            {
                InterestedModel i = new InterestedModel()
                {
                    ad_id          = id,
                    familymembers  = "",
                    name           = "",
                    occupation     = "",
                    phone          = "",
                    presentAddress = "",
                    users_id       = "",
                };
                return(View(i));
            }
            return(View(interestedModel));
        }