public JsonResult GetFlatsMemberInfo(string HouseRenter)
        {
            var HRs = db.HouseRepresentatives.ToList();
            HouseRepresentative HR = HRs.Find(a => a.MobileNo == HouseRenter);
            var flatMembers        = db.FlatMembers.Where(a => a.HouseRepresentativeId == HR.Id).ToList();
            List <ViewMemberList> viewMemberLists = new List <ViewMemberList>();

            foreach (var flatMember in flatMembers)
            {
                string to;
                if (flatMember.LeavingDate == null)
                {
                    to = "Not Leave";
                }
                else
                {
                    to = flatMember.LeavingDate.Value.ToString();
                }
                ViewMemberList viewMemberList = new ViewMemberList()
                {
                    Name     = flatMember.Name,
                    MobileNo = flatMember.MobileNo,
                    From     = flatMember.EntryDate.Date.ToString(),
                    To       = to
                };
                viewMemberLists.Add(viewMemberList);
            }
            return(Json(viewMemberLists, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 2
0
        public ActionResult Registration(HouseRepresentative houseRepresentative)
        {
            ViewBag.OccupationId = new SelectList(db.Occupations, "Id", "Name", houseRepresentative.OccupationId);

            var nationalIdWithMobileNos = db.NationalIdWithMobileNos.ToList();
            var houseRepresetatives     = db.HouseRepresentatives.ToList();

            ViewBag.NationalId      = nationalIdWithMobileNos.Find(a => a.NationalId == houseRepresentative.NationalId && a.MobileNo == houseRepresentative.MobileNo);
            ViewBag.ExistNationalId = houseRepresetatives.Find(a => a.NationalId == houseRepresentative.NationalId);
            if (ViewBag.NationalId != null && ViewBag.ExistNationalId == null)
            {
                db.HouseRepresentatives.Add(houseRepresentative);
                db.SaveChanges();
                var houseRepresentatives2 = db.HouseRepresentatives.ToList();

                HouseRepresentative houseRepresentativeSearch = houseRepresentatives2.Find(a => a.MobileNo == houseRepresentative.MobileNo && a.Password == houseRepresentative.Password);

                Session["houseRepresentativeMobileName"] = houseRepresentativeSearch.MobileNo;
                Session["houseRepresentativeName"]       = houseRepresentativeSearch.Name;
                Session["houseRepresentativeId"]         = houseRepresentativeSearch.Id;

                return(RedirectToAction("Index", "FlatMembers"));
            }

            else
            {
                if (ViewBag.NationalId == null)
                {
                    ViewBag.NationalIdFound = "Id  not Found";
                }
                return(View());
            }
        }
Ejemplo n.º 3
0
        public ActionResult DeleteConfirmed(int id)
        {
            if (Session["houseRepresentativeMobileName"] == null)
            {
                return(RedirectToAction("Index", "HouseRepresentatives"));
            }
            HouseRepresentative houseRepresentative = db.HouseRepresentatives.Find(id);

            db.HouseRepresentatives.Remove(houseRepresentative);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 4
0
 public ActionResult Edit([Bind(Include = "Id,Name,NationalId,MobileNo,OccupationId,UserName,Password,ConfirmPassword")] HouseRepresentative houseRepresentative)
 {
     if (Session["houseRepresentativeMobileName"] == null)
     {
         return(RedirectToAction("Index", "HouseRepresentatives"));
     }
     if (ModelState.IsValid)
     {
         db.Entry(houseRepresentative).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.OccupationId = new SelectList(db.Occupations, "Id", "Name", houseRepresentative.OccupationId);
     return(View(houseRepresentative));
 }
Ejemplo n.º 5
0
        // GET: HouseRepresentatives/Details/5
        public ActionResult Details(int?id)
        {
            if (Session["houseRepresentativeMobileName"] == null)
            {
                return(RedirectToAction("Index", "HouseRepresentatives"));
            }
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            HouseRepresentative houseRepresentative = db.HouseRepresentatives.Find(id);

            if (houseRepresentative == null)
            {
                return(HttpNotFound());
            }
            return(View(houseRepresentative));
        }
        public JsonResult GetRenerFlatsInfo(string HouseRenter)
        {
            var HRs = db.HouseRepresentatives.ToList();
            HouseRepresentative       HR          = HRs.Find(a => a.MobileNo == HouseRenter);
            List <ViewRenterFlatInfo> RenterInfos = new List <ViewRenterFlatInfo>();

            if (HR != null)
            {
                var RentedByAll = db.RentedBys.Include(a => a.Flats.Homes.HouseOwners).ToList();
                var RentedBys   = RentedByAll.Where(a => a.Id == HR.Id).ToList();

                if (RentedBys.Count != 0)
                {
                    foreach (var rentedBy in RentedBys)
                    {
                        string to;
                        if (rentedBy.LeavingDate == null)
                        {
                            to = "Not Leave";
                        }
                        else
                        {
                            to = rentedBy.LeavingDate.Value.ToString();
                        }
                        ViewRenterFlatInfo RenterInfo = new ViewRenterFlatInfo()
                        {
                            HouseName    = rentedBy.Flats.Homes.Name,
                            HouseNo      = rentedBy.Flats.Homes.HomeNo,
                            FlatNo       = rentedBy.Flats.FlatNo,
                            OwnerName    = rentedBy.Flats.Homes.HouseOwners.Name,
                            OwnerMobleNo = rentedBy.Flats.Homes.HouseOwners.MobileNo,
                            From         = rentedBy.EntryDate.Date.ToString(),
                            To           = to
                        };
                        RenterInfos.Add(RenterInfo);
                    }
                }
            }



            return(Json(RenterInfos, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 7
0
        public ActionResult Index(HouseRepresentative houseRepresentative)
        {
            var houseRepresentatives = db.HouseRepresentatives.ToList();

            HouseRepresentative houseRepresentativeSearch = houseRepresentatives.Find(a => a.MobileNo == houseRepresentative.MobileNo && a.Password == houseRepresentative.Password);

            if (houseRepresentativeSearch != null)
            {
                Session["houseRepresentativeMobileName"] = houseRepresentativeSearch.MobileNo;
                Session["houseRepresentativeName"]       = houseRepresentativeSearch.Name;
                Session["houseRepresentativeId"]         = houseRepresentativeSearch.Id;
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                ViewBag.LogInError = "Either Password or UserName Not match!";
                return(View());
            }
        }
Ejemplo n.º 8
0
        // GET: HouseRepresentatives/Edit/5
        public ActionResult Edit(int?id)
        {
            if (Session["houseRepresentativeMobileName"] == null)
            {
                return(RedirectToAction("Index", "HouseRepresentatives"));
            }
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            HouseRepresentative houseRepresentative = db.HouseRepresentatives.Find(id);

            if (houseRepresentative == null)
            {
                return(HttpNotFound());
            }
            ViewBag.OccupationId = new SelectList(db.Occupations, "Id", "Name", houseRepresentative.OccupationId);
            return(View(houseRepresentative));
        }
        public ActionResult Create(RentedBy rentedBy, string MobileNo)
        {
            var homes        = db.Homes.ToList();
            int HouseOwnerId = (int)Session["HouseOwnerId"];

            ViewBag.HomeId = homes.Where(a => a.HouseOwnerId == HouseOwnerId);
            List <HouseRepresentative> houseRepresentatives = db.HouseRepresentatives.ToList();
            HouseRepresentative        houseRepresentative  = houseRepresentatives.Find(a => a.MobileNo == MobileNo);


            if (houseRepresentative == null)
            {
                ViewBag.error = "There is No Representative with this Mobile No";
                return(View());
            }
            List <RentedBy> rentedBys            = db.RentedBys.ToList();
            RentedBy        HRForCheckRentedInfo = rentedBys.Find(a => a.HouseRepresentative == houseRepresentative.Id && a.LeavingDate == null);

            if (HRForCheckRentedInfo != null)
            {
                ViewBag.error = "This House Representaive Allready lives In A House!";
                return(View());
            }
            HRForCheckRentedInfo = rentedBys.Find(a => a.LeavingDate == null && a.FlatId == rentedBy.FlatId);
            if (HRForCheckRentedInfo != null)
            {
                ViewBag.error = "This House has Allready Occupied By Other!";
                return(View());
            }


            rentedBy.HouseRepresentative = houseRepresentative.Id;


            db.RentedBys.Add(rentedBy);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }