public void Test_CPL()
        {
            var expectedState = new CpuState();

            expectedState.Registers.A               = 0x42;
            expectedState.Registers.HalfCarryFlag   = true;
            expectedState.Registers.SubtractionFlag = true;

            var actualState = new CpuState();

            actualState.Registers.A = (byte)(~expectedState.Registers.A);

            var memoryMock = new Mock <IRandomAccessMemory>();

            var instruction = new CPL();

            instruction.Initialize();

            //act
            while (!instruction.IsFetchNecessary())
            {
                instruction.ExecuteCycle(actualState, memoryMock.Object);
            }

            TestHelper.AssertCpuState(expectedState, actualState);
            memoryMock.Verify(m => m.WriteByte(It.IsAny <ushort>(), It.IsAny <byte>()), Times.Never);
        }
Example #2
0
        public ActionResult Add()
        {
            ViewBag.Accounts = (new AirbnbAccountProvider(_dbContext)).AggregatedAccounts();
            var model = new CPL();

            return(View(model));
        }
Example #3
0
        public ActionResult Info(string Id)
        {
            try
            {
                ViewBag.Title = "View Property";
                PropertyProvider dataProvider = new PropertyProvider(_dbContext);
                CPL property = dataProvider.Retrieve(Id);
                if (property == null)
                {
                    return(RedirectToAction("NotFound", "Error"));
                }
                var account = new SelectListItem {
                    Text = property.Account, Value = property.Account
                };
                ViewBag.Accounts = new List <SelectListItem>();
                ViewBag.Accounts.Add(account);
                return(View("Entry", property));
            }
            catch (Exception ex)
            {
                // TODO: log
            }

            return(RedirectToAction("Index", "Property")
                   .WithError("The property item cannot be found."));
        }
Example #4
0
        public ActionResult ModalDetails(string Id)
        {
            if (!AuthorizationProvider.IsViewer())
            {
                return(PartialView("DetailsPartial", new CPL()));
            }

            try
            {
                PropertyProvider propertyProvider = new PropertyProvider(_dbContext);

                ViewBag.Title = "View Property Details";
                CPL details = propertyProvider.Retrieve(Id);
                if (details == null)
                {
                    string message = string.Format("Property '{0}' not found.", Id);
                    DojoLogger.Warn(message, typeof(PropertyController));
                    return(RedirectToAction("NotFound", "Error"));
                }
                return(PartialView("DetailsPartial", details));
            }
            catch (Exception ex)
            {
                string message = string.Format("Retrieve Property Details fails. {0}", ex.Message);
                DojoLogger.Error(message, typeof(PropertyController));
            }

            return(RedirectToAction("Index", "Property")
                   .WithError("The Property cannot be found."));
        }
Example #5
0
        public ActionResult ModalEdit(String Id)
        {
            if (!AuthorizationProvider.IsPropertyEditor() && !AuthorizationProvider.IsViewer())
            {
                return(RedirectToAction("Index", "Property")
                       .WithError("It looks like you do not have permisssion to edit this property."));
            }

            try
            {
                ViewBag.Title      = "Edit Property";
                ViewBag.ButtonText = "Update Property";

                PropertyProvider dataProvider = new PropertyProvider(_dbContext);
                CPL property = dataProvider.Retrieve(Id);
                if (property == null)
                {
                    return(RedirectToAction("NotFound", "Error"));
                }

                InitSelectFields(property);
                ViewBag.Accounts = (new AirbnbAccountProvider(_dbContext)).AggregatedAccounts();
                return(PartialView("_PropertyFormPartial", property));
            }
            catch (Exception)
            {
                // TODO: log
            }

            return(RedirectToAction("Index", "Property")
                   .WithError("The property item cannot be found."));
        }
Example #6
0
        public ActionResult Add(CPL model)
        {
            model.CreatedDate = DateTime.UtcNow;
            try
            {
                if (String.IsNullOrWhiteSpace(model.PropertyCode))
                {
                    ModelState.AddModelError("PropertyCode", "Property Code must be filled");
                }
                else
                {
                    model.PropertyCode = model.PropertyCode.ToUpper();

                    if (_dbContext.CPLs.Find(model.PropertyCode) != null)
                    {
                        ModelState.AddModelError("PropertyCode", "Property with code " + model.PropertyCode + " is already exists");
                    }
                }
                if (ModelState.IsValid)
                {
                    _dbContext.CPLs.Add(model);
                    saveShowErrors(_dbContext);
                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception ex)
            {
                ViewBag.ErrorMessage = "New property was not added: " + ex.GetType().Name + ". " + ex.Message;
                return(View());
            }
            ViewBag.Accounts = (new AirbnbAccountProvider(_dbContext)).AggregatedAccounts();
            return(View());
        }
Example #7
0
        public ActionResult New()
        {
            ViewBag.Title      = "New Property";
            ViewBag.ButtonText = "Add Property";

            var property = new CPL();

            InitSelectFields(property);
            ViewBag.Accounts = (new AirbnbAccountProvider(_dbContext)).AggregatedAccounts();
            return(PartialView("_PropertyFormPartial", property));
        }
Example #8
0
 public ActionResult Edit(CPL cpl)
 {
     if (ModelState.IsValid)
     {
         _dbContext.Entry(cpl).State = EntityState.Modified;
         _dbContext.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.Accounts = (new AirbnbAccountProvider(_dbContext)).AggregatedAccounts();
     return(View(cpl));
 }
Example #9
0
        public ActionResult Edit(String Id = "")
        {
            CPL cpl = _dbContext.CPLs.Find(Id);

            ViewBag.Accounts = (new AirbnbAccountProvider(_dbContext)).AggregatedAccounts();
            if (cpl == null)
            {
                return(RedirectToAction("NotFound", "Error"));
            }

            return(View(cpl));
        }
Example #10
0
 private void InitSelectFields(CPL cpl)
 {
     //if (cpl.NeedsOwnerApproval == null) cpl.NeedsOwnerApproval = false;
     if (cpl.PropertyStatus == null)
     {
         cpl.PropertyStatus = string.Empty;
     }
     if (cpl.BeltDesignation == null)
     {
         cpl.BeltDesignation = string.Empty;
     }
     if (cpl.Account == null)
     {
         cpl.Account = string.Empty;
     }
     if (cpl.Market == null)
     {
         cpl.Market = string.Empty;
     }
     if (cpl.Vertical == null)
     {
         cpl.Vertical = string.Empty;
     }
     if (cpl.Area == null)
     {
         cpl.Area = string.Empty;
     }
     if (cpl.Neighborhood == null)
     {
         cpl.Neighborhood = string.Empty;
     }
     if (cpl.City == null)
     {
         cpl.City = string.Empty;
     }
     if (cpl.Elevator == null)
     {
         cpl.Elevator = string.Empty;
     }
     if (cpl.Pool == null)
     {
         cpl.Pool = string.Empty;
     }
 }
Example #11
0
        public string GetPropertyCodeByListing(string account, string listing)
        {
            string propertyCode = string.Empty;
            CPL    property     = _context.CPLs.Where(p => p.AirBnBHomeName.Contains(listing)).FirstOrDefault();

            if (property != null)
            {
                propertyCode = property.PropertyCode;
            }
            else // try PropertyTitleHistory table
            {
                var entity = _context.PropertyTitleHistories.FirstOrDefault(p => p.PropertyTitle.ToLower() == listing.ToLower());
                if (entity != null)
                {
                    propertyCode = entity.PropertyCode;
                }
            }
            return(propertyCode);
        }
Example #12
0
 private void setInactiveTimestamp(CPL form)
 {
     // set inactive or dead timestamp if its value is changed
     if (form.PropertyStatus.ToLower() == "dead")
     {
         form.Dead     = DateTime.UtcNow;
         form.Inactive = null;
     }
     else if (form.PropertyStatus.ToLower() == "inactive")
     {
         form.Inactive = DateTime.UtcNow;
         form.Dead     = null;
     }
     else
     {
         form.Inactive = null;
         form.Dead     = null;
     }
 }
Example #13
0
        public ActionResult Edit(CPL cpl)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    PropertyProvider dataProvider = new PropertyProvider(_dbContext);
                    dataProvider.Update(cpl.PropertyCode, cpl);
                    dataProvider.Commit();
                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception ex)
            {
                // TODO: log
            }

            ViewBag.Accounts = (new AirbnbAccountProvider(_dbContext)).AggregatedAccounts();
            return(View("Entry", "Property", cpl)
                   .WithError("The property item cannot be updated."));
        }
Example #14
0
        public ActionResult Edit(String Id)
        {
            try
            {
                ViewBag.Title      = "Edit Property";
                ViewBag.ButtonText = "Update Property";

                PropertyProvider dataProvider = new PropertyProvider(_dbContext);
                CPL property = dataProvider.Retrieve(Id);
                if (property == null)
                {
                    return(RedirectToAction("NotFound", "Error"));
                }
                ViewBag.Accounts = (new AirbnbAccountProvider(_dbContext)).AggregatedAccounts();
                return(View("Edit", property));
            }
            catch (Exception ex)
            {
                // TODO: log
            }

            return(RedirectToAction("Index", "Property")
                   .WithError("The property item cannot be found."));
        }
Example #15
0
        public static CPL ToCPL(this string[] s)
        {
            CPL booking = new CPL();


            booking.AirBnBHomeName     = s[0];
            booking.PropertyCode       = s[1];
            booking.Address            = s[2];
            booking.PropertyStatus     = s[3];
            booking.Vertical           = s[4];
            booking.Owner              = s[5];
            booking.NeedsOwnerApproval = s[6].ToNullBool();
            booking.ListingStartDate   = s[7].ToDateTime();
            booking.StreamlineHomeName = s[9];
            booking.StreamlineUnitID   = s[10];
            booking.Account            = s[11];
            booking.City              = s[13];
            booking.Market            = s[14];
            booking.State             = s[15];
            booking.Area              = s[16];
            booking.Neighborhood      = s[17];
            booking.BookingGuidelines = s[19];
            //booking.Quarantine = s[20];
            //booking.Lease_ContractStartDate = s[21].ToDateTime();
            //booking.Lease_ContractEndDate = s[22];
            booking.Floor           = s[23];
            booking.Bedrooms        = s[24].ToNullableInt32();
            booking.Bathrooms       = s[25].ToNullableFloat();
            booking.BedsDescription = s[26];
            booking.MaxOcc          = s[27].ToNullableInt32();
            booking.StdOcc          = s[28].ToNullableInt32();
            booking.Elevator        = s[29];
            booking.A_C             = s[30];
            booking.Parking         = s[31];
            booking.WiFiNetwork     = s[32];
            booking.WiFiPassword    = s[33];
            booking.Ownership       = s[34].ToNullableFloat();
            booking.MonthlyRent     = s[35].ToNullabledecimal();
            booking.DailyRent       = s[36].ToNullabledecimal();
            //booking.MethodofRent_Payment = s[37];
            booking.CleaningFees = s[38].ToNullableInt32();
            //booking.AirBnBURL = s[39];
            booking.AIrBnBID = s[40];
            //booking.HomeTripperURL = s[41];
            booking.AirbnbiCalexportlink = s[42];
            booking.Amenities            = s[43];
            booking.Zipcode                 = s[44];
            booking.CheckInType             = s[45];
            booking.OldListingTitle         = s[46];
            booking.GoogleDrivePicturesLink = s[47];
            booking.SquareFootage           = s[48].ToNullableInt32();
            booking.Password                = s[49];
            booking.Currency                = s[50].CurrencyParse();
            booking.InquiryLeadApproval     = s[51].ToNullBool();
            //booking.RevTeam2xApproval = s[52].ToNullBool();
            booking.PendingContractDate   = s[53].ToDateTime();
            booking.PendingOnboardingDate = s[54].ToDateTime();
            //booking.AccountActive = s[55];
            booking.SecurityDeposit = s[56];
            booking.Pool            = s[57];
            booking.HomeAway        = s[58];
            booking.AirBnb          = s[59];
            booking.FlipKey         = s[60];
            booking.Expedia         = s[61];
            booking.Inactive        = s[62].ToDateTime();

            return(booking);
        }
Example #16
0
        public JsonResult ModalEdit(CPL form)
        {
            if (!AuthorizationProvider.IsPropertyEditor())
            {
                return(Json("denied", JsonRequestBehavior.AllowGet));
            }

            try
            {
                if (ModelState.IsValid)
                {
                    PropertyProvider dataProvider = new PropertyProvider(_dbContext);

                    // make the date to PST time zone to store in DB using UTC
                    if (form.ListingStartDate != null)
                    {
                        form.ListingStartDate = form.ListingStartDate.Value.Date.AddHours(11);
                    }
                    if (form.PendingContractDate != null)
                    {
                        form.PendingContractDate = form.PendingContractDate.Value.Date.AddHours(11);
                    }
                    if (form.PendingOnboardingDate != null)
                    {
                        form.PendingOnboardingDate = form.PendingOnboardingDate.Value.Date.AddHours(11);
                    }

                    bool managementFeeChanged = false;
                    bool titleChanged         = false;
                    if (!dataProvider.PropertyExist(form.PropertyCode)) // new property
                    {
                        titleChanged         = true;
                        managementFeeChanged = true;
                        form.PropertyCode    = form.PropertyCode.ToUpper();
                        // if entity state is EntityState.UnAttached, CreatedDate won't be created. we set it explicitly here just to be sure
                        form.CreatedDate = ConversionHelper.EnsureUtcDate(DateTime.Now.Date);
                        form.CreatedBy   = ClaimsPrincipal.Current.Identity.Name;
                        dataProvider.Create(form);
                    }
                    else // updating property
                    {
                        var property = dataProvider.Retrieve(form.PropertyCode);
                        if (property != null)
                        {
                            titleChanged         = string.Compare(property.AirBnBHomeName, form.AirBnBHomeName, true) != 0;
                            managementFeeChanged = property.Ownership != form.Ownership;

                            if (string.Compare(property.PropertyStatus, form.PropertyStatus, true) != 0)
                            {
                                setInactiveTimestamp(form);
                            }

                            dataProvider.Update(form.PropertyCode, form);
                        }
                    }
                    dataProvider.Commit();

                    // update PropertyTitleHistory table if title has changed
                    if (titleChanged)
                    {
                        var titleProvider = new PropertyTitleHistoryProvider(_dbContext);
                        if (!titleProvider.Exist(form.PropertyCode, form.AirBnBHomeName))
                        {
                            var titleHistory = new PropertyTitleHistory()
                            {
                                PropertyCode  = form.PropertyCode,
                                PropertyTitle = form.AirBnBHomeName,
                                EffectiveDate = ConversionHelper.EnsureUtcDate(DateTime.UtcNow)
                            };
                            titleProvider.Create(titleHistory);
                            titleProvider.Commit();
                        }
                    }

                    // obsolete: Property fee has moved to property fee table
                    if (managementFeeChanged)
                    {
                        // TODO: add a record to PropertyFee table for new management fee
                    }

                    ViewBag.Accounts = (new AirbnbAccountProvider(_dbContext)).AggregatedAccounts();
                    return(Json(form.PropertyCode, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception ex)
            {
                // TODO: log
                this.ModelState.AddModelError("", ex);
            }
            return(Json(string.Empty, JsonRequestBehavior.AllowGet));
        }
 public InquiryInfoViewModel() : base()
 {
     Property = new CPL();
 }
Example #18
0
        public ActionResult Upload(HttpPostedFileBase file)
        {
            try
            {
                List <string[]> csvRows = new List <string[]>();

                // Verify that the user selected a file
                if (file != null && file.ContentLength > 0)
                {
                    // extract only the filename
                    var fileName = Path.GetFileName(file.FileName);
                    // store the file inside ~/App_Data/uploads folder
                    var path = Path.Combine(Server.MapPath("~/App_Data/uploads"), Guid.NewGuid().ToString() + "_" + fileName);
                    file.SaveAs(path);

                    using (var reader = new StreamReader(System.IO.File.OpenRead(path)))
                    {
                        var colCount = reader.ReadLine().Split(',').Length;
                        var parser   = new NetCSVParser();
                        while (!reader.EndOfStream)
                        {
                            var line = reader.ReadToEnd();
                            line.Replace(",#N/A,", ",null,");
                            List <string[]> values = new List <string[]>();
                            values = parser.Parse(path, colCount, ",");
                            values.RemoveAt(0);

                            csvRows = values;
                        }
                    }
                }

                if (csvRows.Count > 0)
                {
                    int expectedLength = csvRows[0].Length;
                    foreach (var item in csvRows)
                    {
                        if (item.Length != expectedLength)
                        {
                            throw new ArgumentException("CSV file is invalid");
                        }
                    }
                }

                if (csvRows.Count() < 1)
                {
                    throw new ArgumentException("File is empty or invalid");
                }

                for (int i = 0; i < csvRows.Count; i++)
                {
                    CPL str = csvRows[i].ToCPL();
                    _dbContext.CPLs.AddOrUpdate(str);
                }
                saveShowErrors(_dbContext);
                _dbContext.SaveChanges();

                ViewBag.UploadMessage = "Data is succesfully uploaded. Existing rows are updated, new rows added. Total rows processed " + csvRows.Count;
                return(View());
            }
            catch (Exception ex)
            {
                ViewBag.ErrorMessage = "Error while uploading data: " + ex.GetType().Name + ". ";
                string message = ViewBag.ErrorMessage + ex.Message;
                RDTLogger.Info(message, typeof(InquiriesValidationController));
                return(View());
            }
        }