Пример #1
0
        private Boolean checkSub2(ListingItem item, string search, string userId)
        {
            string title = item.Title;

            title  = title.ToLower();
            search = search.ToLower();
            char[] tarray = title.ToCharArray();
            char[] sarray = search.ToCharArray();
            if (sarray.Length > tarray.Length)
            {
                return(false);
            }
            for (int i = 0; i < sarray.Length; i++)
            {
                if (tarray[i] != sarray[i])
                {
                    return(false);
                }
            }
            if (item.userId.Equals(userId))
            {
                return(true);
            }
            return(false);
        }
Пример #2
0
        public async Task <IActionResult> PutListingItem([FromRoute] int id, [FromBody] ListingItem listingItem)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != listingItem.Id)
            {
                return(BadRequest());
            }

            _context.Entry(listingItem).State = EntityState.Modified;

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

            return(NoContent());
        }
Пример #3
0
        private ListingItem PopulateListingItemFromDataReader(SqlDataReader dr)
        {
            var listingItem = new ListingItem();

            listingItem.ListingId        = (int)dr["ListingId"];
            listingItem.UserId           = dr["UserId"].ToString();
            listingItem.StateId          = dr["StateId"].ToString();
            listingItem.BathroomTypeId   = (int)dr["BathroomTypeId"];
            listingItem.BathroomTypeName = dr["BathroomTypeName"].ToString();
            listingItem.Nickname         = dr["Nickname"].ToString();
            listingItem.City             = dr["City"].ToString();
            listingItem.Rate             = (decimal)dr["Rate"];
            listingItem.SquareFootage    = (decimal)dr["SquareFootage"];
            listingItem.HasElectric      = (bool)dr["HasElectric"];
            listingItem.HasHeat          = (bool)dr["HasHeat"];

            if (dr["ListingDescription"] != DBNull.Value)
            {
                listingItem.ListingDescription = dr["ListingDescription"].ToString();
            }

            if (dr["ImageFileName"] != DBNull.Value)
            {
                listingItem.ImageFileName = dr["ImageFileName"].ToString();
            }

            return(listingItem);
        }
Пример #4
0
        public async Task <ListingItem> Insert(ListingItem model)
        {
            var result = await _context.ListingItems.AddAsync(model);

            await _context.SaveChangesAsync();

            return(result.Entity);
        }
Пример #5
0
        public async Task <IActionResult> PostListingItem([FromBody] ListingItem listingItem)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.ListingItem.Add(listingItem);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetListingItem", new { id = listingItem.Id }, listingItem));
        }
Пример #6
0
        async void OnListingSelected(ListingItem item)
        {
            if (item == null)
            {
                return;
            }

            await _navigationService.NavigateAsync($"{Screens.ListingDetail}",
                                                   new NavigationParameters($"{ScreensNavigationParameters.ProductId}={item.ProductName}"));

            ItemSelected = null;
        }
Пример #7
0
        public ListingItem ListingGetDetails(int listingId)
        {
            ListingItem listingItem = null;

            using (var cxn = new SqlConnection(cxnStr))
            {
                var parameters = new DynamicParameters();
                parameters.Add("@ListingId", listingId);
                listingItem = cxn.Query <ListingItem>("ListingsSelectDetails", parameters, commandType: CommandType.StoredProcedure).FirstOrDefault();
            }
            return(listingItem);
        }
        public async Task <ListingItemDto> Handle(CreateListingItemCommand request, CancellationToken cancellationToken)
        {
            if (request?.Data == null)
            {
                throw new ListingItemCannotBeCreatedException();
            }

            var model  = ListingItem.Create(request.Data);
            var result = await _repository.Insert(model);

            return(_mapper.Map <ListingItemDto>(result));
        }
Пример #9
0
        private void CopyItemDown(int day)
        {
            DayItem dayItem = _dayItems[day - 1];

            if (_dayItems[day].IsEqual(dayItem))
            {
                return;
            }
            ListingItem newItem = Listing.ReplaceItem(day + 1, dayItem.Locality, dayItem.ListingItem.TimeSetting);

            _dayItems[day].Update(newItem);

            _listingFacade.Save(Listing);
        }
Пример #10
0
        private void RecursiveAdd(ListingItem item, TreeNode target)
        {
            foreach (var child in item.Children)
            {
                if (!child.IsDirectory)
                {
                    continue;
                }

                var childNode = new TreeNode(child.Text, 1, 1);
                target.Nodes.Add(childNode);
                RecursiveAdd(child, childNode);
            }
        }
Пример #11
0
        public ActionResult Index(int projectId = 0)
        {
            var project = new ListingItem(null, null);

            if (projectId != 0)
            {
                var nodeListingProvider = new NodeListingProvider();
                project = (ListingItem)nodeListingProvider.GetListing(projectId);

                var memberId = Members.GetCurrentMemberId();
                if ((project.VendorId == memberId) == false && Utils.IsProjectContributor(memberId, projectId) == false)
                {
                    Response.Redirect("/member/profile/projects/", true);
                }
            }

            var model       = new ProjectDetails();
            var currentPage = Umbraco.TypedContent(UmbracoContext.PageId.Value);
            var rootNode    = currentPage.AncestorOrSelf(1);
            var projects    = rootNode.Children(x => x.ContentType.Alias == "Projects").First();
            var categories  = projects.Children(x => x.ContentType.Alias == "ProjectGroup" && x.GetPropertyValue <bool>("hqOnly") == false);

            model.ProjectCategories = new List <SelectListItem> {
                new SelectListItem {
                    Text = string.Empty, Value = string.Empty
                }
            };
            foreach (var category in categories)
            {
                model.ProjectCategories.Add(new SelectListItem {
                    Text = category.Name, Value = category.Id.ToString(), Selected = project.CategoryId == category.Id
                });
            }

            model.License    = string.IsNullOrWhiteSpace(project.LicenseName) ? "MIT" : project.LicenseName;
            model.LicenseUrl = string.IsNullOrWhiteSpace(project.LicenseUrl) ? "http://www.opensource.org/licenses/mit-license.php" : project.LicenseUrl;

            model.Title                = project.Name;
            model.Description          = project.Description;
            model.Version              = project.CurrentVersion;
            model.SourceCodeUrl        = project.SourceCodeUrl;
            model.DemonstrationUrl     = project.DemonstrationUrl;
            model.OpenForCollaboration = project.OpenForCollab;
            model.GoogleAnalyticsCode  = project.GACode;
            model.Id = projectId;

            return(PartialView("~/Views/Partials/Project/Edit.cshtml", model));
        }
Пример #12
0
        public ListingItem GetDetails(int listingId)
        {
            ListingItem listing = null;

            using (var cn = new SqlConnection(Settings.GetConnectionString()))
            {
                SqlCommand cmd = new SqlCommand("ListingsSelectDetails", cn);
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.AddWithValue("@ListingId", listingId);

                cn.Open();

                using (SqlDataReader dr = cmd.ExecuteReader())
                {
                    if (dr.Read())
                    {
                        listing                  = new ListingItem();
                        listing.ListingId        = (int)dr["ListingId"];
                        listing.UserId           = dr["UserId"].ToString();
                        listing.StateId          = dr["StateId"].ToString();
                        listing.BathroomTypeId   = (int)dr["BathroomTypeId"];
                        listing.Nickname         = dr["Nickname"].ToString();
                        listing.City             = dr["City"].ToString();
                        listing.Rate             = (decimal)dr["Rate"];
                        listing.SquareFootage    = (decimal)dr["SquareFootage"];
                        listing.HasElectric      = (bool)dr["HasElectric"];
                        listing.HasHeat          = (bool)dr["HasHeat"];
                        listing.BathroomTypeName = dr["BathroomTypeName"].ToString();

                        if (dr["ListingDescription"] != DBNull.Value)
                        {
                            listing.ListingDescription = dr["ListingDescription"].ToString();
                        }

                        if (dr["ImageFileName"] != DBNull.Value)
                        {
                            listing.ImageFileName = dr["ImageFileName"].ToString();
                        }
                    }
                }
            }

            return(listing);
        }
Пример #13
0
        private void SaveListingItem()
        {
            ListingItem newItem = _dayItem.Listing.ReplaceItem(
                _dayItem.Day,
                string.IsNullOrEmpty(_locality) ? null : _locality.Trim(),
                new Time(WorkedTimeViewModel.StartTime),
                new Time(WorkedTimeViewModel.EndTime),
                new Time(WorkedTimeViewModel.LunchStart),
                new Time(WorkedTimeViewModel.LunchEnd),
                new Time(WorkedTimeViewModel.OtherHours)
                );

            _listingFacade.Save(_dayItem.Listing);

            DayItem.Update(newItem);

            EventAggregator.PublishOnUIThread(new ChangeViewMessage(nameof(ListingDetailViewModel)));
        }
Пример #14
0
        public IEnumerable <ListingItem> GetListings(string userId)
        {
            List <ListingItem> listings = new List <ListingItem>();

            using (var cn = new SqlConnection(Settings.GetConnectionString()))
            {
                SqlCommand cmd = new SqlCommand("ListingsSelectByUser", cn);
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.AddWithValue("@UserId", userId);

                cn.Open();

                using (SqlDataReader dr = cmd.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        ListingItem row = new ListingItem();

                        row.ListingId        = (int)dr["ListingId"];
                        row.UserId           = dr["UserId"].ToString();
                        row.Nickname         = dr["Nickname"].ToString();
                        row.StateId          = dr["StateId"].ToString();
                        row.City             = dr["City"].ToString();
                        row.Rate             = (decimal)dr["Rate"];
                        row.SquareFootage    = (decimal)dr["SquareFootage"];
                        row.HasElectric      = (bool)dr["HasElectric"];
                        row.HasHeat          = (bool)dr["HasHeat"];
                        row.BathroomTypeName = dr["BathroomTypeName"].ToString();
                        row.BathroomTypeId   = (int)dr["BathroomTypeId"];

                        if (dr["ImageFileName"] != DBNull.Value)
                        {
                            row.ImageFileName = dr["ImageFileName"].ToString();
                        }

                        listings.Add(row);
                    }
                }
            }

            return(listings);
        }
Пример #15
0
        public async Task <IActionResult> UploadFile([FromForm] ImageItem item)
        {
            if (!MultipartRequestHelper.IsMultipartContentType(Request.ContentType))
            {
                return(BadRequest($"Expected a multipart request,but got {Request.ContentType}"));
            }
            try
            {
                using (var stream = item.Image.OpenReadStream())
                {
                    var cloudBlock = await UploadToBlob(item.Image.FileName, null, stream);

                    //// Retrieve the filename of the file you have uploaded
                    //var filename = provider.FileData.FirstOrDefault()?.LocalFileName;
                    if (string.IsNullOrEmpty(cloudBlock.StorageUri.ToString()))
                    {
                        return(BadRequest("An error has occured while uploading your file. Please try again."));
                    }

                    ListingItem listingItem = new ListingItem();
                    listingItem.Title       = item.Title;
                    listingItem.Seller      = item.Seller;
                    listingItem.Price       = item.Price;
                    listingItem.Description = item.Description;
                    listingItem.email       = item.email;
                    listingItem.userId      = item.userId;

                    System.Drawing.Image image = System.Drawing.Image.FromStream(stream);
                    listingItem.Url      = cloudBlock.SnapshotQualifiedUri.AbsoluteUri;
                    listingItem.Uploaded = DateTime.Now.ToString();

                    _context.ListingItem.Add(listingItem);
                    await _context.SaveChangesAsync();

                    return(Ok($"File: {item.Title} has successfully uploaded"));
                }
            }
            catch (Exception ex)
            {
                return(BadRequest($"An error has occured. Details: {ex.Message}"));
            }
        }
Пример #16
0
        void datatransferManager_DataRequested(DataTransferManager sender, DataRequestedEventArgs args)
        {
            ListingItem item = ItemListView.SelectedItem as ListingItem;

            if (item == null)
            {
                args.Request.FailWithDisplayText("You must select a story from the left to share first.");
            }
            args.Request.Data.Properties.Title           = "Link Shared from reddit Metro";
            args.Request.Data.Properties.Description     = item.data.title;
            args.Request.Data.Properties.ApplicationName = "reddit Metro";
            if (item.data.is_self)
            {
                args.Request.Data.SetHtml(item.data.selftext_html);
            }
            else
            {
                args.Request.Data.SetUri(new Uri(item.data.url));
            }
        }
Пример #17
0
        public ListingItem ListingGetDetails(int listingId)
        {
            ListingItem listingItem = null;

            using (var cxn = new SqlConnection(cxnStr))
                using (var cmd = new SqlCommand("ListingsSelectDetails", (SqlConnection)cxn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@ListingId", listingId);
                    cxn.Open();
                    using (SqlDataReader dr = cmd.ExecuteReader())
                    {
                        if (dr.Read())
                        {
                            listingItem = PopulateListingItemFromDataReader(dr);
                        }
                    }
                }
            return(listingItem);
        }
Пример #18
0
        public void CanLoadListingDetails()
        {
            var         repo        = new ListingsRepositoryDapper();
            ListingItem listingItem = repo.ListingGetDetails(1);

            Assert.IsNotNull(listingItem);

            //1, '00000000-0000-0000-0000-000000000000', 'OH', 1, 'Test shack 1', 'Cleveland', 120, 400, 0, 1, 'placeholder.png'
            Assert.AreEqual(1, listingItem.ListingId);
            Assert.AreEqual(Guid.Empty.ToString(), listingItem.UserId);
            Assert.AreEqual("OH", listingItem.StateId);
            Assert.AreEqual(1, listingItem.BathroomTypeId);
            Assert.AreEqual("Indoor", listingItem.BathroomTypeName);
            Assert.AreEqual("Test shack 1", listingItem.Nickname);
            Assert.AreEqual("Cleveland", listingItem.City);
            Assert.AreEqual(100M, listingItem.Rate);
            Assert.AreEqual(400M, listingItem.SquareFootage);
            Assert.AreEqual(false, listingItem.HasElectric);
            Assert.AreEqual(true, listingItem.HasHeat);
            Assert.AreEqual("Description 1", listingItem.ListingDescription);
            Assert.AreEqual("placeholder.png", listingItem.ImageFileName);
        }
Пример #19
0
        private void Reset(DayItem dayItem)
        {
            string date = CultureInfo.CurrentCulture.TextInfo.ToTitleCase((new DateTime(dayItem.Year, dayItem.Month, dayItem.Day)).ToLongDateString().ToLower());

            WindowTitle.Text = String.Format("{0} - {1}", date, dayItem.Listing.Name);
            _defaultSettings = _settingFacade.GetDefaultSettings();
            Locality         = null;

            if (dayItem.ListingItem != null)
            {
                ListingItem l = dayItem.ListingItem;
                Locality = l.Locality;

                WorkedTimeViewModel = new WorkedTimeSettingViewModel(_defaultSettings.Time, l.TimeSetting, _defaultSettings.TimeTickInMinutes);
            }
            else
            {
                WorkedTimeViewModel = new WorkedTimeSettingViewModel(_defaultSettings.Time, _defaultSettings.Time, _defaultSettings.TimeTickInMinutes);
            }

            Localities = new ObservableCollection <string>(dayItem.Localities);
        }
Пример #20
0
        public static ListingItem ConvertToListingItem(IEnumerable <FtpItem> inputItems, string separator)
        {
            var root = new ListingItem("Root", false);

            foreach (var item in inputItems)
            {
                var currentParent = root;
                foreach (
                    var pathSegment in item.FullPath.Remove(0, 1).Split(new[] { separator }, StringSplitOptions.None))
                {
                    var child = currentParent.Children.FirstOrDefault(t => t.Text == pathSegment);
                    if (child == null)
                    {
                        child = new ListingItem(pathSegment, item.ItemType == FtpItemType.Directory);
                        currentParent.Children.Add(child);
                    }
                    currentParent = child;
                }
            }

            return(root);
        }
Пример #21
0
 public ListingItemArgs(ListingItem listingItem)
 {
     ListingItem = listingItem;
 }
Пример #22
0
 public void ConvertToEntityType(ListingItem item)
 {
     var itemData = new ItemConvertor(item);
        Items.Add(itemData);
 }