Example #1
0
        public void AddCategoriesForSportCenter(IEnumerable <string> categoriesNames, string sportCenterName)
        {
            var sportCenter = sportCentesDb.All().FirstOrDefault(x => x.Name == sportCenterName);

            foreach (var name in categoriesNames)
            {
                var currentCategory = this.sportCategoriesDb.All().FirstOrDefault(x => x.Name == name);

                if (currentCategory != null)
                {
                    currentCategory.SportCenters.Add(sportCenter);
                }
                else
                {
                    if (string.IsNullOrWhiteSpace(name))
                    {
                        continue;
                    }
                    sportCategoriesDb.Add(new SportCategory()
                    {
                        Name = name.Trim(), SportCenters = new List <SportCenter>()
                        {
                            sportCenter
                        }
                    });
                }
            }
            sportCategoriesDb.SaveChanges();
        }
Example #2
0
 public void Create(string city, string neighbour)
 {
     addressesDb.Add(new Address()
     {
         City = city, Neighborhood = neighbour
     });
     addressesDb.SaveChanges();
 }
        public void AddDefaultPages(List <Page> pageList)
        {
            foreach (var page in pageList)
            {
                pages.Add(page);
            }

            pages.SaveChanges();
        }
Example #4
0
        public void AddPicture(string name, string fileName)
        {
            Picture pic = new Picture
            {
                Name       = name,
                UrlToImage = Path.Combine("Images", fileName)
            };

            pictures.Add(pic);
            pictures.SaveChanges();
        }
Example #5
0
        public void AddNewVideo(string name, string videoUrl)
        {
            Video vid = new Video
            {
                Name     = name,
                VideoUrl = videoUrl
            };

            videos.Add(vid);
            videos.SaveChanges();
        }
Example #6
0
        public void AddPost(string title, string content, string id)
        {
            Post post = new Post
            {
                Title    = title,
                Content  = content,
                AuthorId = id
            };

            posts.Add(post);

            posts.SaveChanges();
        }
Example #7
0
        public void AddImagesToSportCenter(string sportCenterName, IEnumerable <string> imagesUrl)
        {
            var sportCenter = sportCentersDb.All().FirstOrDefault(x => x.Name == sportCenterName);
            var urls        = new StringBuilder();

            foreach (var imgUrl in imagesUrl)
            {
                urls.Append("," + imgUrl);
            }
            sportCenter.PicturesUrls = urls.ToString();

            sportCentersDb.SaveChanges();
        }
Example #8
0
        public void DeleteUser(string guid)
        {
            var user = users.All().Where(x => x.Id == guid).FirstOrDefault();

            user.IsDeleted = true;
            user.DeletedOn = DateTime.Now;

            users.SaveChanges();
        }
Example #9
0
        public void AddAddressForUser(string userId, int neighbourId)
        {
            var address = addressesDb.All()
                          .FirstOrDefault(x => neighbourId == x.Id);

            var user = usersDb.All().FirstOrDefault(x => x.Id == userId);

            user.AddressId = address.Id;

            usersDb.SaveChanges();
        }
Example #10
0
        public void AddAddressForSportCenter(string sportCenterName, int neighbourId)
        {
            var address = addressesDb.All()
                          .FirstOrDefault(x => neighbourId == x.Id);

            var spotrtCenter = sportCenters.All().FirstOrDefault(x => x.Name == sportCenterName);

            spotrtCenter.AddressId = address.Id;

            sportCenters.SaveChanges();
        }
Example #11
0
        public Log AddNewLog(string category, string content)
        {
            Log log = new Log
            {
                CreatedOn = DateTime.Now,
                Category  = category,
                Content   = content
            };

            logs.Add(log);

            logs.SaveChanges();

            return(log);
        }
Example #12
0
        public void SendMessage(string recieverId, string senderId, string content)
        {
            var reciever = usersDb.All().FirstOrDefault(x => x.Id == recieverId);
            var author   = usersDb.All().FirstOrDefault(x => x.Id == senderId);

            if (author != null && reciever != null)
            {
                var message = new Message()
                {
                    Reciever = reciever, Author = author, Content = content
                };
                messagesDb.Add(message);
                messagesDb.SaveChanges();
            }
            else
            {
                throw new ArgumentNullException("Invalid user ids");
            }
        }
        public ActionResult Ask(AskInputModel input)
        {
            if (ModelState.IsValid)
            {
                var userId = User.Identity.GetUserId();

                var post = new Post
                {
                    Title    = input.Title,
                    Content  = sanitizer.Sanitize(input.Content),
                    AuthorId = userId
                               //TODO: Tags
                };

                posts.Add(post);
                posts.SaveChanges();
                return(RedirectToAction("Display", new { id = post.Id, url = "new" }));
            }
            return(View(input));
        }