public async Task <IActionResult> Edit(int id, [Bind("AdminID,IdentityUserId,EmailAddress")] LandLord landLord)
        {
            if (id != landLord.AdminID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(landLord);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!LandLordExists(landLord.AdminID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["IdentityUserId"] = new SelectList(_context.Users, "Id", "Id", landLord.IdentityUserId);
            return(View(landLord));
        }
예제 #2
0
        public ActionResult ClaimLandLord(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            LandLord landlord = db.LandLords.Find(id);

            if (landlord == null)
            {
                return(HttpNotFound());
            }
            var user = GetCurrentUser();

            if (user.ClaimedLandLordId != 0)
            {
                return(RedirectToAction("AlreadyClaimed"));
            }
            if (landlord.IsClaimed)
            {
                return(RedirectToAction("LandLordAlreadyClaimed", new { id = landlord.LandLordId }));
            }


            ClaimLandLordViewModel vm = new ClaimLandLordViewModel();

            vm.LandLordName        = landlord.FullName;
            TempData["landlordid"] = id;
            return(View(vm));
        }
        public async Task <ActionResult> ApproveLandLordFinal(
            [Bind(Include = "LandLordId,FullName,PhoneNumber,City,State,IsApproved")] int?id)
        {
            if (!IsAdminUser())
            {
                return(RedirectToAction("Unauthorized", "LandLords"));
            }
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            LandLord landLord = await db.LandLords.FindAsync(id);

            if (landLord == null || !IsAdminUser())
            {
                return(HttpNotFound());
            }
            landLord.IsApproved = true;
            ViewBag.Message     = "You have approved the landlord " + landLord.FullName +
                                  ". This account is now live on the website.";
            db.Entry(landLord).State = EntityState.Modified;
            await db.SaveChangesAsync();

            return(RedirectToAction("Index", "Admin"));
        }
        public async Task <ActionResult> DeclineLandLordFinal(
            [Bind(Include = "LandLordId,FullName,PhoneNumber,City,State,IsApproved")] int?id)
        {
            if (!IsAdminUser())
            {
                return(RedirectToAction("Unauthorized", "LandLords"));
            }
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            LandLord landLord = await db.LandLords.FindAsync(id);

            if (landLord == null || !IsAdminUser())
            {
                return(HttpNotFound());
            }
            landLord.IsDeclined     = true;
            landLord.DeclinedReason = "Admin declined";
            if (landLord.IsApproved)
            {
                landLord.IsApproved = false;
            }
            db.Entry(landLord).State = EntityState.Modified;
            await db.SaveChangesAsync();

            ViewBag.Message = "You have declined the landlord page " + landLord.FullName;
            return(RedirectToAction("LandLordsAwaitingApproval", "Admin"));
        }
예제 #5
0
        public async Task <IActionResult> Edit(int id, [Bind("LandLordID,LLName,LLPassID,LLPhone,LLAdress")] LandLord landLord)
        {
            if (id != landLord.LandLordID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(landLord);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!LandLordExists(landLord.LandLordID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(landLord));
        }
예제 #6
0
        public async Task <ActionResult> CreateRating(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            LandLord landLord = await db.LandLords.FindAsync(id);

            if (landLord == null)
            {
                return(HttpNotFound());
            }
            ViewBag.Message = landLord.FullName;
            var user = GetCurrentUser();

            if (user.ClaimedLandLordId == id)
            {
                return(RedirectToAction("Unauthorized"));
            }
            var userid       = user.Id;
            var alreadyrated = db.Ratings.Where(u => u.User.Id == userid).Any(u => u.LandLordId == id);

            if (alreadyrated)
            {
                return(RedirectToAction("AlreadyCreated", "LandLords"));
            }
            Rating r = new Rating();

            r.LandLordId = (int)id;
            return(View(r));
        }
예제 #7
0
        private static List <int> AIGetPai(LandLordUser myu, List <int> _lastDiscard, int _lastpos)
        {
            List <int> _ret             = new List <int>();
            List <int> _lastDiscardtemp = new List <int>(_lastDiscard);

            if (_lastDiscardtemp == null)
            {
                _lastDiscardtemp = new List <int>();
            }
            if (_lastpos == myu._Pos)
            {
                _lastDiscardtemp = new List <int>();
            }

            _ret = LandLord.GetTipList(myu._shouPaiArr, _lastDiscard);
            if (_ret.Count != 0)
            {
                LordPokerTypeEnum _ltype = LandLord.GetLordType(_ret);
                if (_ltype == LordPokerTypeEnum.Error)
                {
                    TraceLogEx.Error("201702212024 fetal error  " + JsonUtils.Serialize(myu._shouPaiArr) + "tip for" + JsonUtils.Serialize(_lastDiscard) + " LordPokerTypeEnum.Error  :" + JsonUtils.Serialize(_ret));
                }
            }
            return(_ret);
        }
 public async Task <ActionResult> AddTestLandLordsFinal()
 {
     if (!IsAdminUser())
     {
         return(RedirectToAction("Unauthorized", "LandLords"));
     }
     try
     {
         var landlordnumber = db.LandLords.Count();
         if (landlordnumber == 0)
         {
             landlordnumber = 1;
         }
         for (int i = landlordnumber; i <= 100; i++)
         {
             var      landlordname = "LandLord" + i;
             LandLord landlord     = new LandLord();
             landlord.FullName            = landlordname;
             landlord.City                = "Cleveland";
             landlord.IndividualOrCompany = IndividualOrCompany.Individual;
             landlord.Description         =
                 "This is just a test landlord! Here is some information about this landlord. What a great/terrible landlord this landlord is! Yay!";
             landlord.PhoneNumber = "1231231234";
             landlord.State       = States.OH;
             landlord.IsApproved  = true;
             landlord.ZipCode     = "44145";
             var gls     = new GoogleLocationService();
             var latlong = gls.GetLatLongFromAddress(landlord.City + " " + landlord.ZipCode);
             landlord.Latitude  = latlong.Latitude;
             landlord.Longitude = latlong.Longitude;
             db.LandLords.Add(landlord);
             List <Rating> ratings = new List <Rating>();
             for (int k = 1; i <= 10; i++)
             {
                 Rating rating = new Rating();
                 rating.RatingName        = "Rating" + k;
                 rating.LandLord          = landlord;
                 rating.ContactPhoneNumer = UnspecifiedYesNo.Yes;
                 rating.LandLordRating    = 2;
                 rating.LateFees          = UnspecifiedYesNo.Yes;
                 rating.IsApproved        = true;
                 rating.RatingDescription = landlord.FullName + " is a terrible landlord! I'd never recommend this guy!";
                 rating.RatingName        = "Terrible landlord";
                 RatingReply ratingreply = new RatingReply();
                 ratingreply.ReplyDescription = "Thanks for the review!";
                 ratingreply.Rating           = rating;
                 db.Ratings.Add(rating);
                 db.RatingReplies.Add(ratingreply);
             }
             await db.SaveChangesAsync();
         }
         ViewBag.Message = "Success! 100 landlords with 10 ratings were added.";
     }
     catch (SystemException ex)
     {
         ViewBag.Message = ex.Message;
     }
     return(View());
 }
예제 #9
0
 public ActionResult ClaimSubmitted(LandLord landlord)
 {
     if (landlord == null)
     {
         return(HttpNotFound());
     }
     return(View());
 }
예제 #10
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            LandLord landLord = await db.LandLords.FindAsync(id);

            db.LandLords.Remove(landLord);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
        public async Task <IActionResult> Create([Bind("AdminID,IdentityUserId,EmailAddress")] LandLord landLord)
        {
            if (ModelState.IsValid)
            {
                _context.Add(landLord);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["IdentityUserId"] = new SelectList(_context.Users, "Id", "Id", landLord.IdentityUserId);
            return(View(landLord));
        }
예제 #12
0
        // GET: LandLords/Details/5
        public async Task <ActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            LandLord landLord = await db.LandLords.FindAsync(id);

            if (landLord == null || !landLord.IsApproved)
            {
                return(HttpNotFound());
            }
            LandLordViewModel vm = new LandLordViewModel();

            vm.LandLord = landLord;
            if (db.Ratings.Count(u => u.LandLordId == id && u.IsApproved) > 5)
            {
                vm.AreThereMoreThan5Ratings = true;
            }
            else
            {
                vm.AreThereMoreThan5Ratings = false;
            }
            vm.Ratings =
                db.Ratings.Where(u => u.LandLordId == id && u.IsApproved)
                .OrderBy(u => u.LandLordRating)
                .Take(5)
                .ToPagedList(1, 10);
            if (db.PublicRecords.Count(u => u.LandLord.LandLordId == id && u.IsApproved) > 5)
            {
                vm.AreThereMoreThan5PublicRecords = true;
            }
            else
            {
                vm.AreThereMoreThan5PublicRecords = false;
            }
            vm.PublicRecords =
                db.PublicRecords.Where(u => u.LandLord.LandLordId == id && u.IsApproved)
                .OrderBy(u => u.CaseName)
                .Take(5)
                .ToPagedList(1, 10);
            var user = GetCurrentUser();

            if (user != null)
            {
                var userid = user.Id;
                vm.IsClaimingUser = db.Users.Any(u => u.ClaimedLandLordId == landLord.LandLordId && u.Id == userid);
            }

            return(View(vm));
        }
예제 #13
0
        //Action used when a landlord has already been claimed by another user
        public ActionResult LandLordAlreadyClaimed(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            LandLord landlord = db.LandLords.Find(id);

            if (landlord == null)
            {
                return(HttpNotFound());
            }
            return(View(landlord));
        }
예제 #14
0
        public async Task <ActionResult> FlagSubmitted(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            LandLord landLord = await db.LandLords.FindAsync(id);

            //Update to use flag view model instead of flag.
            //Flag flag = db.Flags.FirstOrDefault(u => u.FlaggedObjectId == id);
            if (landLord == null)
            {
                return(HttpNotFound());
            }
            return(View(landLord));
        }
예제 #15
0
        public async Task <ActionResult> Create(
            [Bind(Include = "LandLordId,FullName,PhoneNumber,City,State,IsDeclined,IsApproved,Description,ProfileImageUrl,LandLordOrTenant,IndividualOrCompany,OverallRating,IsApproved,IsClaimed,IsDeclined,IsClaimedDuringCreation,DeclinedReason,ZipCode,Latitude,Longitude")] LandLord landLord)
        {
            string userResponse = HttpContext.Request.Params["g-recaptcha-response"];
            bool   validCaptcha = ReCaptcha.ValidateCaptcha(userResponse);

            if (!validCaptcha)
            {
                // A bot, not validated !
                return(RedirectToAction("Unauthorized", "Account"));
            }
            if (IsAdminUser())
            {
                landLord.IsApproved = true;
                landLord.IsDeclined = false;
            }
            else
            {
                landLord.IsApproved = false;
                landLord.IsDeclined = false;
            }
            if (ModelState.IsValid)
            {
                var gls     = new GoogleLocationService();
                var latlong = gls.GetLatLongFromAddress(landLord.City + " " + landLord.ZipCode);
                landLord.Latitude  = latlong.Latitude;
                landLord.Longitude = latlong.Longitude;
                db.LandLords.Add(landLord);
                await db.SaveChangesAsync();

                if (landLord.IsClaimedDuringCreation)
                {
                    landLord.IsClaimed = true;
                    var user = GetCurrentUser();
                    if (user.ClaimedLandLordId != 0)
                    {
                        return(RedirectToAction("CannotClaim"));
                    }
                    user.ClaimedLandLordId = landLord.LandLordId;
                    db.Entry(user).State   = EntityState.Modified;
                    await db.SaveChangesAsync();
                }
                return(RedirectToAction("Index"));
            }

            return(View(landLord));
        }
예제 #16
0
        public IActionResult SaveLandLordRegistration(AddingLandLordVM model)
        {
            if (!ModelState.IsValid)
            {
                return(View("LandLordRegistration", LListInput(model)));
            }

            var contact = new ContactInfo()
            {
                Email   = model.Email,
                Phone   = model.PhoneNummber,
                Address = model.Address
            };

            db.Contact.Add(contact);
            db.SaveChanges();

            var profileInfo = new ProfileInfo()
            {
                Username     = model.Username,
                PasswordSalt = PasswordHashAndSalt.GenerateSalt()
            };

            profileInfo.PasswordHash = PasswordHashAndSalt.GenerateHash(profileInfo.PasswordSalt, model.Password);
            db.ProfileInfo.Add(profileInfo);
            db.SaveChanges();

            var newLandLord = new LandLord()
            {
                Fname         = model.FName,
                LName         = model.LName,
                DateOfBirth   = model.DateOfBirth,
                DateAdded     = DateTime.Today,
                ContactInfoId = contact.Id,
                CityId        = model.CityId,
                StatusId      = 1,
                GenderId      = model.GenderId,
                ProfileInfoId = profileInfo.Id
            };

            db.LandLord.Add(newLandLord);
            db.SaveChanges();

            return(RedirectToAction("Index"));
        }
        public async Task <ActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            LandLord landLord = await db.LandLords.FindAsync(id);

            if (landLord == null || !IsAdminUser())
            {
                return(HttpNotFound());
            }
            LandLordViewModel vm = new LandLordViewModel();

            vm.LandLord = landLord;
            vm.Ratings  = db.Ratings.Where(u => u.LandLordId == id).OrderBy(u => u.LandLordRating).ToPagedList(1, 10);
            return(View(vm));
        }
        public async Task <ActionResult> DeclineLandLord(int?id)
        {
            if (!IsAdminUser())
            {
                return(RedirectToAction("Unauthorized", "LandLords"));
            }
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            LandLord landLord = await db.LandLords.FindAsync(id);

            if (landLord == null || !IsAdminUser())
            {
                return(HttpNotFound());
            }
            return(View(landLord));
        }
예제 #19
0
        public ActionResult SubmitPublicRecord(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            LandLord landlord = db.LandLords.Find(id);

            if (landlord == null || !landlord.IsApproved)
            {
                return(HttpNotFound());
            }

            PublicRecord record = new PublicRecord();

            record.LandLord        = landlord;
            TempData["landlordid"] = landlord.LandLordId;
            return(View(record));
        }
예제 #20
0
        public async Task <ActionResult> Edit(
            [Bind(Include = "LandLordId,FullName,PhoneNumber,City,State,IsApproved")] LandLord landLord)
        {
            var currentuser = GetCurrentUser();

            if (IsAdminUser() || currentuser.ClaimedLandLordId == landLord.LandLordId)
            {
                if (ModelState.IsValid)
                {
                    db.Entry(landLord).State = EntityState.Modified;
                    await db.SaveChangesAsync();

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

                (View(landLord));
        }
예제 #21
0
        public async Task <ActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            LandLord landLord = await db.LandLords.FindAsync(id);

            var currentuser = GetCurrentUser();

            if (currentuser.ClaimedLandLordId != landLord.LandLordId)
            {
                return(RedirectToAction("Unauthorized"));
            }

            if (landLord == null || !IsAdminUser())
            {
                return(HttpNotFound());
            }
            return(View(landLord));
        }
예제 #22
0
        public ActionResult UploadProfileImage(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            LandLord landlord = db.LandLords.Find(id);

            if (landlord == null)
            {
                return(HttpNotFound());
            }

            var user = GetCurrentUser();

            TempData["landlordid"] = id;
            if (user.ClaimedLandLordId == landlord.LandLordId)
            {
                return(View(landlord));
            }
            return(RedirectToAction("Unauthorized"));
        }
예제 #23
0
        public async Task <IActionResult> Create([Bind("LLName,LLPassID,LLPhone,LLAdress")] LandLord landLord)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    _context.Add(landLord);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction(nameof(Index)));
                }
                return(View(landLord));
            }
            catch (DbUpdateException /* ex */)
            {
                //Log the error (uncomment ex variable name and write a log.
                ModelState.AddModelError("", "Unable to save changes. " +
                                         "Try again, and if the problem persists " +
                                         "see your system administrator.");
            }
            return(View(landLord));
        }
예제 #24
0
        public async Task <ActionResult> FlagLandLord(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var userid = User.Identity.GetUserId();

            if (db.Flags.Any(u => u.FlaggedObjectId == id && u.ApplicationUser.Id == userid))
            {
                return(RedirectToAction("Unauthorized", "LandLords"));
            }
            LandLord landLord = await db.LandLords.FindAsync(id);

            if (landLord == null)
            {
                return(HttpNotFound());
            }
            Flag flag = new Flag();

            flag.FlaggedObjectId = (int)id;
            flag.FlaggedObject   = FlaggedObject.LandLord;
            return(View(flag));
        }
예제 #25
0
        public static void Initialize(AgrarianContext context)
        {
            context.Database.EnsureCreated();

            // Look for any students.
            if (context.VillageCouncils.Any())
            {
                return;   // DB has been seeded
            }

            var villageCounsils = new VillageCouncil[]
            {
                new VillageCouncil {
                    VCName = "Бабин"
                },
                new VillageCouncil {
                    VCName = "Лубни"
                },
                new VillageCouncil {
                    VCName = "Пирятин"
                }
            };

            foreach (VillageCouncil vc in villageCounsils)
            {
                context.VillageCouncils.Add(vc);
            }
            context.SaveChanges();

            var fields = new Field[]
            {
                new Field {
                    FieldName = 11, VCID = 1
                },
                new Field {
                    FieldName = 12, VCID = 1
                },
                new Field {
                    FieldName = 13, VCID = 1
                },
                new Field {
                    FieldName = 14, VCID = 1
                },
                new Field {
                    FieldName = 21, VCID = 2
                },
                new Field {
                    FieldName = 22, VCID = 2
                },
                new Field {
                    FieldName = 23, VCID = 2
                },
                new Field {
                    FieldName = 24, VCID = 2
                },
                new Field {
                    FieldName = 25, VCID = 2
                },
                new Field {
                    FieldName = 31, VCID = 3
                },
                new Field {
                    FieldName = 32, VCID = 3
                }
            };

            foreach (Field f in fields)
            {
                context.Fields.Add(f);
            }
            context.SaveChanges();

            var complications = new Complication[]
            {
                new Complication {
                    ComplicationName = "немає", ComplicationInfo = ""
                },
                new Complication {
                    ComplicationName = "болото", ComplicationInfo = ""
                },
                new Complication {
                    ComplicationName = "ліс", ComplicationInfo = ""
                },
                new Complication {
                    ComplicationName = "рельєф", ComplicationInfo = ""
                }
            };

            foreach (Complication c in complications)
            {
                context.Complications.Add(c);
            }
            context.SaveChanges();

            var shares = new Share[]
            {
                new Share {
                    ShareName = 111, FiledID = 1, ComplicationID = 1, ShareArea = 6.05, ShareRealArea = 6.05, ShareCN = "1234567891:34:345:2345"
                },
                new Share {
                    ShareName = 112, FiledID = 1, ComplicationID = 1, ShareArea = 7.05, ShareRealArea = 7.00, ShareCN = "1234567891:34:345:2346"
                },
                new Share {
                    ShareName = 113, FiledID = 2, ComplicationID = 1, ShareArea = 8.05, ShareRealArea = 8.00, ShareCN = "1234567891:34:345:2347"
                },
                new Share {
                    ShareName = 114, FiledID = 2, ComplicationID = 2, ShareArea = 5.05, ShareRealArea = 4.05, ShareCN = "1234567891:34:345:2348"
                },
                new Share {
                    ShareName = 211, FiledID = 2, ComplicationID = 1, ShareArea = 2.05, ShareRealArea = 1.05, ShareCN = "1234567891:34:345:2349"
                },
                new Share {
                    ShareName = 212, FiledID = 3, ComplicationID = 1, ShareArea = 5.45, ShareRealArea = 3.05, ShareCN = "1234567891:34:345:2323"
                },
                new Share {
                    ShareName = 311, FiledID = 4, ComplicationID = 1, ShareArea = 7.45, ShareRealArea = 7.45, ShareCN = "1234567891:34:345:2324"
                },
                new Share {
                    ShareName = 411, FiledID = 5, ComplicationID = 3, ShareArea = 2.05, ShareRealArea = 2.05, ShareCN = "1234567891:34:345:2325"
                },
                new Share {
                    ShareName = 234, FiledID = 5, ComplicationID = 1, ShareArea = 6.35, ShareRealArea = 6.05, ShareCN = "1234567891:34:345:2326"
                },
                new Share {
                    ShareName = 345, FiledID = 6, ComplicationID = 1, ShareArea = 34.5, ShareRealArea = 34.5, ShareCN = "1234567891:34:345:2327"
                },
                new Share {
                    ShareName = 657, FiledID = 7, ComplicationID = 1, ShareArea = 3.05, ShareRealArea = 3.05, ShareCN = "1234567891:34:345:2328"
                },
                new Share {
                    ShareName = 745, FiledID = 8, ComplicationID = 1, ShareArea = 4.05, ShareRealArea = 6.05, ShareCN = "1234567891:34:345:2329"
                },
                new Share {
                    ShareName = 239, FiledID = 9, ComplicationID = 2, ShareArea = 6.05, ShareRealArea = 6.05, ShareCN = "1234567891:34:345:2330"
                },
                new Share {
                    ShareName = 269, FiledID = 9, ComplicationID = 1, ShareArea = 6.05, ShareRealArea = 6.05, ShareCN = "1234567891:34:345:2331"
                },
                new Share {
                    ShareName = 568, FiledID = 9, ComplicationID = 1, ShareArea = 1.05, ShareRealArea = 1.05, ShareCN = "1234567891:34:345:2332"
                },
                new Share {
                    ShareName = 340, FiledID = 10, ComplicationID = 4, ShareArea = 3.05, ShareRealArea = 3.05, ShareCN = "1234567891:34:345:2333"
                },
                new Share {
                    ShareName = 415, FiledID = 10, ComplicationID = 1, ShareArea = 4.05, ShareRealArea = 4.05, ShareCN = "1234567891:34:345:2334"
                },
                new Share {
                    ShareName = 336, FiledID = 10, ComplicationID = 1, ShareArea = 8.05, ShareRealArea = 6.05, ShareCN = "1234567891:34:345:2335"
                },
                new Share {
                    ShareName = 444, FiledID = 10, ComplicationID = 3, ShareArea = 3.05, ShareRealArea = 3.05, ShareCN = "1234567891:34:345:2336"
                },
                new Share {
                    ShareName = 555, FiledID = 11, ComplicationID = 1, ShareArea = 6.05, ShareRealArea = 6.05, ShareCN = "1234567891:34:345:2337"
                },
                new Share {
                    ShareName = 666, FiledID = 11, ComplicationID = 1, ShareArea = 4.05, ShareRealArea = 4.05, ShareCN = "1234567891:34:345:2338"
                },
                new Share {
                    ShareName = 777, FiledID = 11, ComplicationID = 1, ShareArea = 6.05, ShareRealArea = 6.05, ShareCN = "1234567891:34:345:2339"
                }
            };

            foreach (Share sh in shares)
            {
                context.Shares.Add(sh);
            }
            context.SaveChanges();

            var landLords = new LandLord[]
            {
                new LandLord {
                    LLName = "Ткаленко Наталія Павлівна", LLPassID = "1234567891", LLPhone = "+380501234567", LLAdress = "Київ"
                },
                new LandLord {
                    LLName = "Іванчук Віктор Сергійович", LLPassID = "1234567892", LLPhone = "+380502234567", LLAdress = "Київ"
                },
                new LandLord {
                    LLName = "Мельник Іван Степанович", LLPassID = "1234567893", LLPhone = "+380503234567", LLAdress = "ЛЬвів"
                },
                new LandLord {
                    LLName = "Пшенична Любов Олександрівна", LLPassID = "1234567894", LLPhone = "+380504234567", LLAdress = "Львів"
                },
                new LandLord {
                    LLName = "Панасюк Антоніна Ярославівна", LLPassID = "1234567895", LLPhone = "+380505234567", LLAdress = "Тернопіль"
                },
                new LandLord {
                    LLName = "Максимчук Олександр Григорович", LLPassID = "1234567896", LLPhone = "+380506234567", LLAdress = "Тернопіль"
                },
                new LandLord {
                    LLName = "Абрамчук Віталій Ігорович", LLPassID = "1234567897", LLPhone = "+380507234567", LLAdress = "Тернопіль"
                },
                new LandLord {
                    LLName = "Василенко Ігор Васильвоич", LLPassID = "1234567898", LLPhone = "+380508234567", LLAdress = "Суми"
                },
                new LandLord {
                    LLName = "Дивак Галина Володимирівна", LLPassID = "1234567899", LLPhone = "+380509234567", LLAdress = "Суми"
                },
                new LandLord {
                    LLName = "Ковальчук Олег Павлович", LLPassID = "1234567811", LLPhone = "+380501034567", LLAdress = "Суми"
                }
            };

            foreach (LandLord ll in landLords)
            {
                context.LandLords.Add(ll);
            }
            context.SaveChanges();



            var contracts = new Contract[]
            {
                new Contract {
                    LLID = 1, ShareID = 1, ContractBegin = DateTime.Parse("2018-09-01"), ContractEnd = DateTime.Parse("2023-09-01")
                },
                new Contract {
                    LLID = 1, ShareID = 2, ContractBegin = DateTime.Parse("2018-09-01"), ContractEnd = DateTime.Parse("2023-09-01")
                },
                new Contract {
                    LLID = 1, ShareID = 3, ContractBegin = DateTime.Parse("2018-09-01"), ContractEnd = DateTime.Parse("2023-09-01")
                },
                new Contract {
                    LLID = 2, ShareID = 4, ContractBegin = DateTime.Parse("2018-09-01"), ContractEnd = DateTime.Parse("2023-09-01")
                },
                new Contract {
                    LLID = 2, ShareID = 5, ContractBegin = DateTime.Parse("2018-09-01"), ContractEnd = DateTime.Parse("2023-09-01")
                },
                new Contract {
                    LLID = 2, ShareID = 6, ContractBegin = DateTime.Parse("2018-09-01"), ContractEnd = DateTime.Parse("2023-09-01")
                },
                new Contract {
                    LLID = 3, ShareID = 7, ContractBegin = DateTime.Parse("2018-09-01"), ContractEnd = DateTime.Parse("2023-09-01")
                },
                new Contract {
                    LLID = 3, ShareID = 8, ContractBegin = DateTime.Parse("2018-09-01"), ContractEnd = DateTime.Parse("2023-09-01")
                },
                new Contract {
                    LLID = 4, ShareID = 9, ContractBegin = DateTime.Parse("2018-09-01"), ContractEnd = DateTime.Parse("2023-09-01")
                },
                new Contract {
                    LLID = 4, ShareID = 10, ContractBegin = DateTime.Parse("2018-09-01"), ContractEnd = DateTime.Parse("2023-09-01")
                },
                new Contract {
                    LLID = 5, ShareID = 11, ContractBegin = DateTime.Parse("2018-09-01"), ContractEnd = DateTime.Parse("2023-09-01")
                },
                new Contract {
                    LLID = 5, ShareID = 12, ContractBegin = DateTime.Parse("2018-09-01"), ContractEnd = DateTime.Parse("2023-09-01")
                },
                new Contract {
                    LLID = 6, ShareID = 13, ContractBegin = DateTime.Parse("2018-09-01"), ContractEnd = DateTime.Parse("2023-09-01")
                },
                new Contract {
                    LLID = 6, ShareID = 14, ContractBegin = DateTime.Parse("2018-09-01"), ContractEnd = DateTime.Parse("2023-09-01")
                },
                new Contract {
                    LLID = 7, ShareID = 15, ContractBegin = DateTime.Parse("2018-09-01"), ContractEnd = DateTime.Parse("2023-09-01")
                },
                new Contract {
                    LLID = 7, ShareID = 16, ContractBegin = DateTime.Parse("2018-09-01"), ContractEnd = DateTime.Parse("2023-09-01")
                },
                new Contract {
                    LLID = 8, ShareID = 17, ContractBegin = DateTime.Parse("2018-09-01"), ContractEnd = DateTime.Parse("2023-09-01")
                },
                new Contract {
                    LLID = 8, ShareID = 18, ContractBegin = DateTime.Parse("2018-09-01"), ContractEnd = DateTime.Parse("2023-09-01")
                },
                new Contract {
                    LLID = 9, ShareID = 19, ContractBegin = DateTime.Parse("2018-09-01"), ContractEnd = DateTime.Parse("2023-09-01")
                },
                new Contract {
                    LLID = 9, ShareID = 20, ContractBegin = DateTime.Parse("2018-09-01"), ContractEnd = DateTime.Parse("2023-09-01")
                },
                new Contract {
                    LLID = 10, ShareID = 21, ContractBegin = DateTime.Parse("2018-09-01"), ContractEnd = DateTime.Parse("2023-09-01")
                },
                new Contract {
                    LLID = 10, ShareID = 22, ContractBegin = DateTime.Parse("2018-09-01"), ContractEnd = DateTime.Parse("2023-09-01")
                },
            };

            foreach (Contract c in contracts)
            {
                context.Contracts.Add(c);
            }
            context.SaveChanges();
        }
예제 #26
0
        public async Task <ActionResult> ViewLandLordPublicRecords(int?id, string sortOrder, string currentFilter,
                                                                   string searchString, int?page)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            LandLord landLord = await db.LandLords.FindAsync(id);

            if (landLord == null)
            {
                return(HttpNotFound());
            }
            ViewBag.CurrentSort  = sortOrder;
            ViewBag.NameSortParm = string.IsNullOrEmpty(sortOrder) ? "name_desc" : "";
            ViewBag.DateSortParm = sortOrder == "Date" ? "date_desc" : "Date";

            if (searchString != null)
            {
                page = 1;
            }
            else
            {
                searchString = currentFilter;
            }

            ViewBag.CurrentFilter = searchString;
            var recordlist = db.PublicRecords.Where(u => u.LandLord.LandLordId == id && u.IsApproved);

            if (!string.IsNullOrEmpty(searchString))
            {
                recordlist = recordlist.Where(s => s.CaseName.Contains(searchString));
            }

            switch (sortOrder)
            {
            case "name_desc":
                recordlist = recordlist.OrderByDescending(s => s.CaseName);
                break;

            case "Date":
                recordlist = recordlist.OrderBy(s => s.DateFiled);
                break;

            case "date_desc":
                recordlist = recordlist.OrderByDescending(s => s.DateFiled);
                break;

            default:     // Name ascending
                recordlist = recordlist.OrderBy(s => s.CaseName);
                break;
            }


            int pageSize   = 10;
            int pageNumber = (page ?? 1);

            ViewBag.Message = "Viewing Public Records for " + landLord.FullName;
            LandLordViewModel vm = new LandLordViewModel();

            vm.PublicRecords = recordlist.ToPagedList(pageNumber, pageSize);
            vm.LandLord      = landLord;
            var userid = GetCurrentUser().Id;

            vm.IsClaimingUser = db.Users.Any(u => u.ClaimedLandLordId == landLord.LandLordId && u.Id == userid);
            return(View(vm));
        }