public async Task <IHttpActionResult> PutOpenHouse(int id, OpenHouse openHouse)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != openHouse.OpenHouseId)
            {
                return(BadRequest());
            }

            db.Entry(openHouse).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!OpenHouseExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 2
0
        public void CreateOpenHouse(OpenHouse openHouse)
        {
            EstateBrokersContext dbcontext = new EstateBrokersContext();

            dbcontext.OpenHouses.Add(openHouse);
            dbcontext.SaveChanges();
        }
Exemplo n.º 3
0
 public void CreateOpenHouse(OpenHouse openHouse)
 {
     try
     {
         EFDatabase ef = new EFDatabase();
         ef.CreateOpenHouse(openHouse);
     }
     catch (Exception)
     {
         throw;
     }
 }
        public async Task <IHttpActionResult> PostOpenHouse(OpenHouse openHouse)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.OpenHouses.Add(openHouse);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = openHouse.OpenHouseId }, openHouse));
        }
Exemplo n.º 5
0
        /// <summary>
        /// Knappen opretter en instans af OpenHouse klassen og kalder metoden
        /// ReturnOpenHouseEvenly. Information herfra inds�ttes i openHousePairs variablen
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnMakeSelection_Click(object sender, EventArgs e)
        {
            priceCasePair.Clear();
            foreach (Case cases in properties)
            {
                priceCasePair.Add(new KeyValuePair <decimal, Case>(cases.NewestAskingPrice, cases));
            }

            OpenHouse openHouse = new OpenHouse(agents, priceCasePair);

            openHousePairs = openHouse.ReturnOpenHouseEvenly();
            UpdateList();
        }
        public async Task <IHttpActionResult> DeleteOpenHouse(int id)
        {
            OpenHouse openHouse = await db.OpenHouses.FindAsync(id);

            if (openHouse == null)
            {
                return(NotFound());
            }

            db.OpenHouses.Remove(openHouse);
            await db.SaveChangesAsync();

            return(Ok(openHouse));
        }
Exemplo n.º 7
0
        public async Task <OpenHouseViewModel> Handle(CreateOpenHouseCommand request, CancellationToken cancellationToken)
        {
            var oh = new OpenHouse(request.RentalPropertyId, request.OpenhouseDate, request.StartTime,
                                   request.EndTime, request.IsActive, request.Notes, DateTime.Now, DateTime.Now);

            var listing = await _context.PropertyListing
                          .Include(l => l.Contact)
                          .Include(l => l.RentalProperty)
                          .FirstAsync(l => l.RentalPropertyId == request.RentalPropertyId);

            _context.OpenHouse.Add(oh);

            var newOpenHouse = new OpenHouseViewModel();

            newOpenHouse.OpenhouseDate = request.OpenhouseDate;
            newOpenHouse.IsActive      = request.IsActive;
            newOpenHouse.StartTime     = request.StartTime;
            newOpenHouse.EndTime       = request.EndTime;
            newOpenHouse.Notes         = request.Notes;

            var openProeprty = _context.RentalProperty.Include(a => a.Address).FirstOrDefault(p => p.Id == request.RentalPropertyId);

            newOpenHouse.RentalPropertyId = openProeprty.Id;
            newOpenHouse.PropertyName     = openProeprty.PropertyName;
            newOpenHouse.PropertyType     = openProeprty.PropertyType;

            newOpenHouse.streetCity        = openProeprty.Address.StreetNum;
            newOpenHouse.streetCity        = openProeprty.Address.City;
            newOpenHouse.PropertyType      = openProeprty.Address.StateProvince;
            newOpenHouse.streetPostZipCode = openProeprty.Address.ZipPostCode;
            newOpenHouse.Listing           = listing;
            newOpenHouse.Viewers           = null;

            try
            {
                await _context.SaveChangesAsync();

                newOpenHouse.Id = oh.Id;

                // Send message to message queue if needed
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(newOpenHouse);

            //throw new NotImplementedException();
        }
Exemplo n.º 8
0
 private void updateNextOpenHouseDate()
 {
     if (co != null)
     {
         OpenHouse oh = OpenHouseControllerSingleton.Instance().GetNextOpenHouse(co.CaseOrderId);
         if (oh != null)
         {
             lbl_nextOpenHouse.Text = Convert.ToDateTime(oh.Date).ToShortDateString();
         }
         else
         {
             lbl_nextOpenHouse.Text = "Ingen planlagte";
         }
     }
 }
Exemplo n.º 9
0
        public ActionResult FinalPage(OpenHouse oh)
        {
            using (OpenHouseContext ohc = new OpenHouseContext())
            {
                int idToUse = ohc.OpenHouse.Select(m => m.id).Max(); // get latest if needed
                var data    = ohc.OpenHouse.Where(m => m.id == idToUse).FirstOrDefault();


                data.Announcements = oh.Announcements;
                data.OpenDays      = oh.OpenDays;
                data.WhatToBring   = oh.WhatToBring;
                ohc.SaveChanges();
            }
            return(RedirectToAction("Index", "Admin"));
        }
Exemplo n.º 10
0
        public HttpResponseMessage Put(OpenHouse openhouse)
        {
            HttpResponseMessage response;

            try
            {
                openHouseRepository.UpdateOpenHouse(openhouse);
                openHouseRepository.Save();
            }
            catch (Exception ex)
            {
                response = Request.CreateResponse(HttpStatusCode.InternalServerError, "Error");
                return(response);
            }
            response = Request.CreateResponse(HttpStatusCode.OK, "Success");
            return(response);
        }
        public async Task <IActionResult> OpenHouseSubmission(OpenHouseViewModel model)
        {
            if (ModelState.IsValid)
            {
                AppUser AppUser = await _userManager.FindByIdAsync(model.AppUserId);

                var openHouse = new OpenHouse(model, AppUser);

                _repo.AddEntity(openHouse);
                _repo.SaveChanges();

                var emailOpenHouseViewModel = new EmailOpenHouseViewModel(model, AppUser);
                _emailSender.SendEmailAsync("*****@*****.**", $"{AppUser.FirstName} {AppUser.LastName} has submitted an Open House", "OpenHouseSubmission", emailOpenHouseViewModel);

                ModelState.Clear();
                return(Redirect("/OpenHouseSubmission/OpenHouseSuccess"));
            }
            /* Read http://blog.staticvoid.co.nz/2012/entity_framework-navigation_property_basics_with_code_first/ */
            return(View());
        }
        public async Task <IHttpActionResult> PostOpenHouse(OpenHouse openHouse)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            openHouse.OpenHouseCreatedDateTime = openHouse.OpenHouseLastUpdatedDateTime = DateTime.Now;
            db.OpenHouses.Add(openHouse);
            await db.SaveChangesAsync();

            //load listing name
            db.Entry(openHouse).Reference(x => x.Listing).Load();

            var openHouseDTO = new OpenHouseDTO()
            {
                OpenHouseId        = openHouse.OpenHouseId,
                OpenHouseBeginDate = openHouse.OpenHouseBeginDate,
                OpenHouseEndDate   = openHouse.OpenHouseEndDate,
                ListingId          = openHouse.ListingId,
                ListingName        = openHouse.Listing.ListingName
            };

            return(CreatedAtRoute("DefaultApi", new { id = openHouse.OpenHouseId }, openHouseDTO));
        }
Exemplo n.º 13
0
 public void InsertOpenHouse(OpenHouse openHouse)
 {
     openHouseContext.OpenHouses.Add(openHouse);
 }
Exemplo n.º 14
0
        public void DeleteOpenHouse(int openHouseId)
        {
            OpenHouse openHouse = openHouseContext.OpenHouses.Find(openHouseId);

            openHouseContext.OpenHouses.Remove(openHouse);
        }
Exemplo n.º 15
0
 public void DeleteOpenHouse(OpenHouse OpenHouse)
 {
     OpenHouseRepository.Delete(OpenHouse);
 }
Exemplo n.º 16
0
 public void UpdateOpenHouse(OpenHouse OpenHouse)
 {
     OpenHouseRepository.Update(OpenHouse);
 }
Exemplo n.º 17
0
 public void InsertOpenHouse(OpenHouse OpenHouse)
 {
     OpenHouseRepository.Insert(OpenHouse);
 }
Exemplo n.º 18
0
        public void RegisterDefaultAdmin(String secretCode)
        {
            if (secretCode.Equals("7617ed14946fe0c5005b301a30b15820e8a012db"))
            {
                XmlDocument doc = new XmlDocument();
                //doc.Load("books.xml");
                doc.Load(System.Web.Hosting.HostingEnvironment.MapPath("~/admin.xml"));

                //Display all the book titles.
                XmlNodeList nodes = doc.DocumentElement.SelectNodes("/admin");

                foreach (XmlNode node in nodes)
                {
                    string adminEmail = node.SelectSingleNode("email").InnerText;
                    string pass       = node.SelectSingleNode("pass").InnerText;

                    var user = new ApplicationUser {
                        UserName = adminEmail, Email = adminEmail
                    };
                    var result = UserManager.Create(user, pass);
                    if (result.Succeeded)
                    {
                        // Create the Users Model
                        UserModel _userModel = new UserModel();
                        using (UserContext db = new UserContext())
                        {
                            Guid newGuid = Guid.Parse(user.Id);

                            /*
                             * Need to create the association between database
                             * Should create this on user registration which should be first form!
                             * NOTE! We are not creating the array'd objects yet as we need to still
                             * figure out how to handle them in the database
                             */

                            _userModel.UserID = newGuid;
                            _userModel.Email  = user.Email;
                            //_userModel.Birthday = new Date();
                            //_userModel.Birthday
                            _userModel.Birthday                              = DateTime.Now;
                            _userModel.BirthPlace                            = new BirthPlaceLocation();
                            _userModel.BirthPlace.UserID                     = newGuid;
                            _userModel.ConsideredRaceAndEthnicity            = new RaceEthnicity();
                            _userModel.ConsideredRaceAndEthnicity.UserID     = newGuid;
                            _userModel.HealthInfo                            = new Health();
                            _userModel.HealthInfo.UserID                     = newGuid;
                            _userModel.HealthInfo.SeriousInjuryOrSurgeryDate = DateTime.Now;
                            _userModel.SchoolInfo                            = new SchoolInfo();
                            _userModel.SchoolInfo.UserID                     = newGuid;
                            _userModel.LivesWith                             = new LivesWith();
                            _userModel.LivesWith.UserID                      = newGuid;
                            _userModel.MilitaryInfo                          = new MilitaryInfo();
                            _userModel.MailingAddress                        = new Address();
                            _userModel.MailingAddress.UserID                 = newGuid;
                            _userModel.Name                         = new Name();
                            _userModel.Name.UserID                  = newGuid;
                            _userModel.PhoneInfo                    = new Phone();
                            _userModel.PhoneInfo.UserID             = newGuid;
                            _userModel.ResidentAddress              = new Address();
                            _userModel.ResidentAddress.UserID       = newGuid;
                            _userModel.Retainment                   = new Retained();
                            _userModel.Retainment.UserID            = newGuid;
                            _userModel.StudentChildCare             = new ChildCare();
                            _userModel.StudentChildCare.UserID      = newGuid;
                            _userModel.StudentsParentingPlan        = new ParentPlan();
                            _userModel.StudentsParentingPlan.UserID = newGuid;
                            _userModel.LastUpdateDate               = DateTime.Now;
                            _userModel.role                         = new Roles();

                            _userModel.role.isAdmin = true;

                            // now add the form info
                            db.Users.Add(_userModel);
                            try
                            {
                                db.SaveChanges();
                            }
                            catch (DbEntityValidationException ex)
                            {
                                foreach (var entityValidationErrors in ex.EntityValidationErrors)
                                {
                                    foreach (var validationError in entityValidationErrors.ValidationErrors)
                                    {
                                        Response.Write("Property: " + validationError.PropertyName + " Error: " + validationError.ErrorMessage);
                                    }
                                }
                            }
                        }
                    }

                    if (!CheckIfOpenHouseTableExists())
                    {
                        OpenHouse ohObj = new OpenHouse();
                        ohObj.OpenDays    = "Every Tuesday at 5:30PM & Thursday at 11AM";
                        ohObj.WhatToBring = "A picture id as well as signed forms";
                        using (OpenHouseContext ohc = new OpenHouseContext())
                        {
                            ohc.OpenHouse.Add(ohObj);
                            try
                            {
                                ohc.SaveChanges();
                            }
                            catch (DbEntityValidationException ex)
                            {
                                foreach (var entityValidationErrors in ex.EntityValidationErrors)
                                {
                                    foreach (var validationError in entityValidationErrors.ValidationErrors)
                                    {
                                        Response.Write("Property: " + validationError.PropertyName + " Error: " + validationError.ErrorMessage);
                                    }
                                }
                            }
                        }
                    }


                    if (!CheckIfIncomeTableExists())
                    {
                        //await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false);

                        string[] income1  = { "$ 0 to 1, 860", "$ 0 to 930", "$ 0 to 859", "$ 0 to 430", "$ 0 to 22,311" };
                        string[] income2  = { "$ 1,861 to 2,504", "$ 931 to 1,252", "$ 860 to 1,156", "$ 431 to 578", "$ 22,312 to 30,044" };
                        string[] income3  = { "$ 2,505 to 3,149", "$ 1,253 to 1,575", "$ 1,157 to 1,453", "$ 579 to 727", "$ 30,045 to 37,777" };
                        string[] income4  = { "$ 3,150 to 3,793", "$ 1,576 to 1,897", "$ 1,454 to 1,751", "$ 728 to 876", "$ 37,778 to 45,510" };
                        string[] income5  = { "$ 3,794 to 4,437", "$ 1,898 to 2,219", "$ 1,752 to 2,048", "$ 877 to 1,024", "$ 46,511 to 53,243" };
                        string[] income6  = { "$ 4,438 to 5,082", "$ 2,220 to 2,541", "$ 2,049 to 2,346", "$ 1,025 to 1,173", "$ 53,244 to 60,976" };
                        string[] income7  = { "$ 5,083 to 5,726", "$ 2,542 to 2,863", "$ 2,347 to 2,643", "$ 1,174 to 1,322", "$ 60,977 to 68,709" };
                        string[] income8  = { "$ 5,727 to 6,371", "$ 2,864 to 3,186", "$ 2,644 to 2,941", "$ 1,323 to 1,471", "$ 68,710 to 76,442" };
                        string[] income9  = { "$ 6,372 to 7,016", "$ 3, 187 to 3,509", "$ 2,942 to 3,239", "$ 1,472 to 1,620", "$ 76,443 to 84,175" };
                        string[] income10 = { "$ 7,107 to 7,661", "$ 3,510 to 3,832", "$ 3,240 to 3,537", "$ 1,621 to 1,769", "$ 84,176 to 91,908" };
                        string[] income11 = { "$ 7,662 to 8,306", "$ 3,833 to 4,155", "$ 3,538 to 3,835", "$ 1,770 to 1,918", "$ 91,909 to 99,641" };
                        string[] income12 = { "$ 8,307 to 8,951", "$ 4,156 to 4,478", "$ 3,836 to 4,133", "$ 1,919 to 2,067", "$ 99,642 to 107,374" };
                        string[] income13 = { "$ 8,952 to 9,596", "$ 4,479 to 4,801", "$ 4,134 to 4,431", "$ 2,068 to 2,216", "$ 107,375 to 115,107" };
                        string[] income14 = { "$ 9,597 to 10,241", "$ 4,802 to 5,124", "$ 4,432 to 4,729", "$ 2,217 to 2,365", "$ 115,108 to 122,840" };
                        string[] income15 = { "$ 10,242 to 10,886", "$ 5,125 to 5,447", "$ 4,730 to 5,027", "$ 2,366 to 2,514", "$ 122,841 to 130,573" };

                        using (var ic = new IncomeContext())
                        {
                            List <string[]> list = new List <string[]>();
                            list.Add(income1);
                            list.Add(income2);
                            list.Add(income3);
                            list.Add(income4);
                            list.Add(income5);
                            list.Add(income6);
                            list.Add(income7);
                            list.Add(income8);
                            list.Add(income9);
                            list.Add(income10);
                            list.Add(income11);
                            list.Add(income12);
                            list.Add(income13);
                            list.Add(income14);
                            list.Add(income15);

                            FamilyIncome income = new FamilyIncome();
                            income.incomeTable      = new List <IncomeTable>();
                            income.id               = 0;
                            income.EffectiveDates   = "Income Chart Effective from July 1, 2017 through June 30, 2018";
                            income.IncomeTableYears = "2017-18 Family Income Survey";
                            for (int i = 0; i < list.Count; i++)
                            {
                                IncomeTable table = new IncomeTable();
                                table.Monthly      = list[i][0];
                                table.TwiceMonthly = list[i][1];
                                table.TwoWeeks     = list[i][2];
                                table.Weekly       = list[i][3];
                                table.Annually     = list[i][4];
                                income.incomeTable.Add(table);
                            }

                            ic.Income.Add(income);
                            try
                            {
                                ic.SaveChanges();
                            }
                            catch (DbEntityValidationException ex)
                            {
                                foreach (var entityValidationErrors in ex.EntityValidationErrors)
                                {
                                    foreach (var validationError in entityValidationErrors.ValidationErrors)
                                    {
                                        Response.Write("Property: " + validationError.PropertyName + " Error: " + validationError.ErrorMessage);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 19
0
 public void CreateOpenHouse(OpenHouse item)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 20
0
 public void UpdateOpenHouse(OpenHouse openHouse)
 {
     openHouseContext.Entry(openHouse).State = EntityState.Modified;
 }