示例#1
0
        public static AirbnbAccount ToAirbnbAccounts(this string[] s)
        {
            AirbnbAccount AA = new AirbnbAccount();

            AA.Email                 = s[0];
            AA.Password              = s[1];
            AA.Gmailpassword         = s[2];
            AA.Status                = s[3];
            AA.DateAdded             = s[4].ToDateTime();
            AA.SecondaryAccountEmail = s[5];
            AA.AccountAdmin          = s[6];
            AA.Vertical              = s[7];
            AA.Owner_Company         = s[8];
            AA.Name                  = s[9];
            AA.PhoneNumber1          = s[10];
            AA.PhoneNumberOwner      = s[11];
            AA.DOB1                  = s[12].ToDateTime();
            AA.Payout_Method         = s[13];
            AA.PointofContact        = s[14];
            AA.PhoneNumber2          = s[15];
            AA.DOB2                  = s[16].ToDateTime();
            AA.EmailAddress          = s[17];
            AA.ActiveListings        = s[18].ToNullableInt32();
            AA.Pending_Onboarding    = s[19].ToNullableInt32();
            AA.In_activeListings     = s[20].ToNullableInt32();
            AA.ofListingsinLAMarket  = s[21].ToNullableInt32();
            AA.ofListingsinNYCMarket = s[22].ToNullableInt32();
            AA.ProxyIP               = s[23];
            AA.C2ndProxyIP           = s[24];

            return(AA);
        }
示例#2
0
        public ActionResult Edit(AirbnbAccount AirbnbAccount)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    AirbnbAccountProvider dataProvider = new AirbnbAccountProvider(_dbContext);
                    if (AirbnbAccount.Id == 0)
                    {
                        dataProvider.Create(AirbnbAccount);
                    }
                    else
                    {
                        dataProvider.Update(AirbnbAccount.Id, AirbnbAccount);
                    }
                    dataProvider.Commit();
                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception ex)
            {
                // TODO: log
            }

            return(View("Entry", "AirbnbAccount", AirbnbAccount)
                   .WithError("The Airbnb Account item cannot be updated."));
        }
示例#3
0
        public ActionResult Delete(int Id = 0)
        {
            AirbnbAccount airbnbAccount = _dbContext.AirbnbAccounts.Find(Id);

            _dbContext.AirbnbAccounts.Attach(airbnbAccount);
            _dbContext.AirbnbAccounts.Remove(airbnbAccount);
            saveShowErrors(_dbContext);
            return(RedirectToAction("Index"));
        }
示例#4
0
 public ActionResult Edit(AirbnbAccount model)
 {
     if (ModelState.IsValid)
     {
         _dbContext.Entry(model).State = EntityState.Modified;
         _dbContext.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(model));
 }
示例#5
0
        public ActionResult New()
        {
            ViewBag.Title      = "New Airbnb Account";
            ViewBag.ButtonText = "Add Airbnb Account";

            var account = new AirbnbAccount();

            account.Vertical = string.Empty;
            account.Status   = string.Empty;
            return(PartialView("_AirbnbAccountNewFormPartial", account));
        }
示例#6
0
        public ActionResult Edit(int Id = 0)
        {
            AirbnbAccount ctvid = _dbContext.AirbnbAccounts.Find(Id);

            if (ctvid == null)
            {
                return(RedirectToAction("NotFound", "Error"));
            }
            ctvid.ActiveListings        = _dbContext.CPLs.Where(o => o.Account == ctvid.Email).Count(o => o.PropertyStatus == "Active");
            ctvid.Pending_Onboarding    = _dbContext.CPLs.Where(o => o.Account == ctvid.Email).Count(o => o.PropertyStatus == "Pending - Onboarding");
            ctvid.In_activeListings     = _dbContext.CPLs.Where(o => o.Account == ctvid.Email).Count(o => o.PropertyStatus == "Inactive");
            ctvid.ofListingsinLAMarket  = _dbContext.CPLs.Where(o => o.Account == ctvid.Email).Where(o => o.PropertyStatus == "Active").Count(o => o.Market == "Los Angeles");
            ctvid.ofListingsinNYCMarket = _dbContext.CPLs.Where(o => o.Account == ctvid.Email).Where(o => o.PropertyStatus == "Active").Count(o => o.Market == "New York");
            return(View(ctvid));
        }
示例#7
0
 public ActionResult Add(AirbnbAccount model)
 {
     if (ModelState.IsValid)
     {
         model.ActiveListings        = _dbContext.CPLs.Where(o => o.Account == model.Email).Count(o => o.PropertyStatus == "Active");
         model.Pending_Onboarding    = _dbContext.CPLs.Where(o => o.Account == model.Email).Count(o => o.PropertyStatus == "Pending - Onboarding");
         model.In_activeListings     = _dbContext.CPLs.Where(o => o.Account == model.Email).Count(o => o.PropertyStatus == "Inactive");
         model.ofListingsinLAMarket  = _dbContext.CPLs.Where(o => o.Account == model.Email).Where(o => o.PropertyStatus == "Active").Count(o => o.Market == "Los Angeles");
         model.ofListingsinNYCMarket = _dbContext.CPLs.Where(o => o.Account == model.Email).Where(o => o.PropertyStatus == "Active").Count(o => o.Market == "New York");
         _dbContext.AirbnbAccounts.Add(model);
         saveShowErrors(_dbContext);
         return(RedirectToAction("Index"));
     }
     return(View(model));
 }
示例#8
0
        public ActionResult ModalEdit(int Id)
        {
            if (!AuthorizationProvider.IsAccountEditor() && !AuthorizationProvider.IsViewer())
            {
                return(RedirectToAction("Index", "AirbnbAccount")
                       .WithError("It looks like you do not have permisssion to edit this Airbnb account."));
            }

            try
            {
                ViewBag.Title      = "Edit Airbnb Account";
                ViewBag.ButtonText = "Update Airbnb Account";

                AirbnbAccountProvider dataProvider = new AirbnbAccountProvider(_dbContext);
                AirbnbAccount         account      = dataProvider.Retrieve(Id);
                if (account == null)
                {
                    return(RedirectToAction("NotFound", "Error"));
                }

                PropertyProvider propertyProvider = new PropertyProvider(_dbContext);
                var relatedProperties             = propertyProvider.GetAirbnbAccountRelatedProperties(account.Email);
                account.ActiveListings        = relatedProperties.ActiveListings;
                account.In_activeListings     = relatedProperties.InactiveListings;
                account.ofListingsinLAMarket  = relatedProperties.ListingsInLAMarket;
                account.ofListingsinNYCMarket = relatedProperties.ActiveListings;
                account.Pending_Onboarding    = relatedProperties.PendingOnboarding;
                if (account.Vertical == null)
                {
                    account.Vertical = string.Empty;
                }
                if (account.Status == null)
                {
                    account.Status = string.Empty;
                }

                return(PartialView("_AirbnbAccountEditFormPartial", account));
            }
            catch (Exception ex)
            {
                // TODO: log
            }

            return(RedirectToAction("Index", "AirbnbAccount")
                   .WithError("The Airbnb Account item cannot be found."));
        }
示例#9
0
        public ActionResult Edit(int id)
        {
            try
            {
                ViewBag.Title      = "Edit Airbnb Account";
                ViewBag.ButtonText = "Update Airbnb Account";

                AirbnbAccountProvider dataProvider  = new AirbnbAccountProvider(_dbContext);
                AirbnbAccount         AirbnbAccount = dataProvider.Retrieve(id);
                if (AirbnbAccount == null)
                {
                    return(RedirectToAction("NotFound", "Error"));
                }
                return(View("Edit", AirbnbAccount));
            }
            catch (Exception ex)
            {
                // TODO: log
            }

            return(RedirectToAction("Index", "AirbnbAccount")
                   .WithError("The Airbnb Account item cannot be found."));
        }
示例#10
0
        public JsonResult ModalEdit(AirbnbAccount form)
        {
            if (!AuthorizationProvider.IsAccountEditor())
            {
                return(Json("denied", JsonRequestBehavior.AllowGet));
            }

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

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

                    if (form.Id == 0) // new airbnb account
                    {
                        //form.DateAdded = DateTime.Now.Date;
                        PropertyProvider propertyProvider = new PropertyProvider(_dbContext);
                        var relatedProperties             = propertyProvider.GetAirbnbAccountRelatedProperties(form.Email);
                        form.ActiveListings        = relatedProperties.ActiveListings;
                        form.In_activeListings     = relatedProperties.InactiveListings;
                        form.ofListingsinLAMarket  = relatedProperties.ListingsInLAMarket;
                        form.ofListingsinNYCMarket = relatedProperties.ActiveListings;
                        form.Pending_Onboarding    = relatedProperties.PendingOnboarding;
                        dataProvider.Create(form);
                    }
                    else // updating airbnb account
                    {
                        var account = dataProvider.Retrieve(form.Id);
                        if (account != null)
                        {
                            // need to set CreatedBy and CreatedDate a they are not part of form
                            form.CreatedDate = account.CreatedDate;
                            form.CreatedBy   = account.CreatedBy;
                            dataProvider.Update(form.Id, form);
                        }
                    }
                    dataProvider.Commit();

                    return(Json(form.Id.ToString(), JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception ex)
            {
                // TODO: log
                this.ModelState.AddModelError("", ex);
            }
            return(Json(string.Empty, JsonRequestBehavior.AllowGet));
        }
示例#11
0
        public ActionResult Add()
        {
            var model = new AirbnbAccount();

            return(View(model));
        }
示例#12
0
        public ActionResult Upload(HttpPostedFileBase file)
        {
            try
            {
                List <string[]> csvRows = new List <string[]>();
                if (file != null && file.ContentLength > 0)
                {
                    var fileName = Path.GetFileName(file.FileName);
                    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;
                        while (!reader.EndOfStream)
                        {
                            var line = reader.ReadToEnd();
                            line.Replace(",#N/A,", ",null,");
                            List <string[]> values = new List <string[]>();
                            var             parser = new NetCSVParser();
                            values = parser.Parse(path, colCount, "\t");
                            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("TSV file is invalid");
                        }
                    }
                }

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

                for (int i = 0; i < csvRows.Count; i++)
                {
                    AirbnbAccount str = csvRows[i].ToAirbnbAccounts();
                    _dbContext.AirbnbAccounts.Add(str);
                }
                saveShowErrors(_dbContext);
                _dbContext.SaveChanges();
                ViewBag.UploadMessage = "Data is succesfully uploaded";
                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());
            }
        }