Ejemplo n.º 1
0
        public async Task <IActionResult> Create([Bind("Id,Title,Image,HtmlDescription,PostDate,Categories")] BlogsViewModel blogsViewModel)
        {
            if (ModelState.IsValid)
            {
                string filename = "";
                if (blogsViewModel.Image != null && blogsViewModel.Image.Length > 0)
                {
                    filename = Guid.NewGuid().ToString().Substring(4) + blogsViewModel.Image.FileName;
                    UploadFile(blogsViewModel.Image, filename);
                }
                Blog row = new Blog {
                    Image = filename, MediaType = blogsViewModel.MediaType, Title = blogsViewModel.Title, HtmlDescription = blogsViewModel.HtmlDescription, PostDate = blogsViewModel.PostDate, Gallery = blogsViewModel.Gallery
                };
                string[] catIds = Request.Form["Categories"].ToString().Split(',');

                var dbcats = _context.BlogCategories.Where(x => catIds.Contains(x.Id.ToString())).ToList();
                foreach (var dbcat in dbcats)
                {
                    _context.BlogCategoryRelations.Add(new BlogCategoryRelation {
                        Category = dbcat, Blog = row
                    });
                }

                _context.Blogs.Add(row);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(blogsViewModel));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,comment,author,email,subject,rating,DateIn,Status")] VendorItemReview vendorItemReviews, int itemId)
        {
            if (ModelState.IsValid)
            {
                var parms = new Dictionary <string, string>
                {
                    { "itemId", itemId.ToString() }
                };
                string userId = "";
                if (!string.IsNullOrEmpty(Request.Form["User"]))
                {
                    userId = Request.Form["User"];
                }
                else
                {
                    userId = _userManager.GetUserId(User);
                }
                var user = _context.Users.Find(userId);
                var item = _context.VendorItems.Find(itemId);
                _context.Update(vendorItemReviews);

                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index), parms));
            }
            return(View(vendorItemReviews));
        }
        public async Task <IActionResult> PutVendorItemReview([FromRoute] long id, [FromBody] VendorItemReview vendorItemReview)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(NoContent());
        }
        public async Task <IActionResult> Create([Bind("Id,Image")] TopicGalleryViewModel topicGallery)
        {
            if (ModelState.IsValid)
            {
                foreach (var img in topicGallery.Image)
                {
                    string filename = "";
                    if (img != null)
                    {
                        filename = Guid.NewGuid().ToString().Substring(4) + img.FileName;
                        UploadFile(img, filename);
                    }
                    TopicGallery TopicGallery = new TopicGallery {
                        Id = topicGallery.Id, Image = filename
                    };
                    _context.TopicGalleries.Add(TopicGallery);
                    await _context.SaveChangesAsync();
                }

                return(RedirectToAction(nameof(Index)));
            }
            var gallery = _context.Blogs.ToList();

            ViewBag.gallery = new SelectList(gallery, "Id", "Image");
            return(View(topicGallery));
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> Create([Bind("Id,Title,HtmlDescription,JobStatus,Pages,WideImage,Thumb")] CareerViewModel career)
        {
            if (ModelState.IsValid)
            {
                string filename = "";
                if (career.WideImage != null)
                {
                    filename = Guid.NewGuid().ToString().Substring(4) + career.WideImage.FileName;
                    UploadFile(career.WideImage, filename);
                }
                if (career.Thumb != null)
                {
                    filename = Guid.NewGuid().ToString().Substring(4) + career.Thumb.FileName;
                    UploadFile(career.Thumb, filename);
                }
                Career careers = new Career {
                    Id = career.Id, Title = career.Title, HtmlDescription = career.HtmlDescription, WideImage = filename, Thumb = filename, JobStatus = career.JobStatus, Pages = career.Pages
                };
                _context.Careers.Add(careers);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            var pages = _context.Pages.ToList();

            ViewBag.Pages = new SelectList(pages, "Id", "Title");
            return(View(career));
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> PostEvents(string UTitle, string UDescription, DateTime UDate, string UUserId, bool UIsPrivate, IFormFile UImage)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            string filename = "";

            if (UImage != null && UImage.Length > 0)
            {
                filename = UImage.FileName;
                UploadFile(UImage, filename);
            }
            var row = _context.Events.Where(x => x.UserId == Request.Form["UUserId"]).FirstOrDefault();

            if (row == null)
            {
                row = new Events {
                    Date = DateTime.Parse(Request.Form["UDate"].ToString()), Description = Request.Form["UDescription"], Title = Request.Form["UTitle"], UserId = Request.Form["UUserId"], Image = filename, IsPrivate = bool.Parse(Request.Form["UIsPrivate"])
                };
                _context.Events.Add(row);
            }
            else
            {
                row.Date        = DateTime.Parse(Request.Form["UDate"].ToString());
                row.Description = Request.Form["UDescription"];
                row.Title       = Request.Form["UTitle"];
                row.Image       = filename;
                row.IsPrivate   = bool.Parse(Request.Form["UIsPrivate"]);
            }
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetEvents", new { id = row.Id }, row));
        }
        public async Task <IActionResult> Create([Bind("Id,Image")] OffersGalleryViewModel offersGalleryViewModel)
        {
            if (ModelState.IsValid)
            {
                string filename = "";
                if (offersGalleryViewModel.Image != null && offersGalleryViewModel.Image.Length > 0)
                {
                    filename = Guid.NewGuid().ToString().Substring(4) + offersGalleryViewModel.Image.FileName;
                    UploadFile(offersGalleryViewModel.Image, filename);
                }
                string userId = "";
                if (!string.IsNullOrEmpty(Request.Form["User"]))
                {
                    userId = Request.Form["User"];
                }
                else
                {
                    userId = _userManager.GetUserId(User);
                }
                var        user       = _context.Users.Find(userId);
                HomeSlider homeSlider = new HomeSlider {
                    Media = filename, MediaType = offersGalleryViewModel.MediaType
                };
                _context.Add(homeSlider);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(offersGalleryViewModel));
        }
        public async Task <IActionResult> PutGuestList([FromRoute] int id, [FromBody] GuestList guestList)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(NoContent());
        }
        public async Task <IActionResult> Create([Bind("Id,Quantity,TotalPrice")] BasketItems basketItems)
        {
            if (ModelState.IsValid)
            {
                _context.Add(basketItems);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(basketItems));
        }
Ejemplo n.º 10
0
        public async Task <IActionResult> Create([Bind("Id,Status,ReferenceNumber,TransactionUUID,TransactionDate,Total")] Order order)
        {
            if (ModelState.IsValid)
            {
                _context.Add(order);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(order));
        }
        public async Task <IActionResult> Create([Bind("Id")] OffersCategory offersCategory)
        {
            if (ModelState.IsValid)
            {
                _context.Add(offersCategory);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(offersCategory));
        }
        public async Task <IActionResult> Create([Bind("Id,FullName,GuestStatus,Side,Email,Phone,Address")] GuestList guestList)
        {
            if (ModelState.IsValid)
            {
                _context.Add(guestList);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(guestList));
        }
Ejemplo n.º 13
0
        public async Task <IActionResult> Create([Bind("Id,Title,HtmlDescription")] Pages pages)
        {
            if (ModelState.IsValid)
            {
                _context.Add(pages);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(pages));
        }
Ejemplo n.º 14
0
        public async Task <IActionResult> Create([Bind("Id,comment,author,email,subject,rating,DateIn,Status")] VendorItemReview vendorItemReview)
        {
            if (ModelState.IsValid)
            {
                _context.Add(vendorItemReview);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(vendorItemReview));
        }
        public async Task <IActionResult> Create([Bind("Id,TipsTitle,FeaturedVendorsTitle,BlogTitle,ContactAddress,ContactEmail,ContactPhone,AdminEmail,AdminEmailPassword")] WebContent webContent)
        {
            if (ModelState.IsValid)
            {
                _context.Add(webContent);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(webContent));
        }
        public async Task <IActionResult> Create([Bind("Id")] WishList wishList)
        {
            if (ModelState.IsValid)
            {
                _context.Add(wishList);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(wishList));
        }
Ejemplo n.º 17
0
        public async Task <IActionResult> Create([Bind("Id")] BlogCategoryRelation blogCategoryRelation)
        {
            if (ModelState.IsValid)
            {
                _context.Add(blogCategoryRelation);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(blogCategoryRelation));
        }
Ejemplo n.º 18
0
        public async Task <IActionResult> Create([Bind("Id,ProfileId,AccessKey,SecuritySign,PaymentType,RecurringFrequency")] PaymentSetting paymentSetting)
        {
            if (ModelState.IsValid)
            {
                _context.Add(paymentSetting);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(paymentSetting));
        }
Ejemplo n.º 19
0
        public async Task <IActionResult> Create([Bind("Id,Description,EstimatedCost,ActualCost,PaidCost,Notes")] Budget budget)
        {
            if (ModelState.IsValid)
            {
                _context.Add(budget);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(budget));
        }
Ejemplo n.º 20
0
        public async Task <IActionResult> Create([Bind("Id,VendorItemId")] VendorItemTypeValue vendorItemTypeValue)
        {
            if (ModelState.IsValid)
            {
                _context.Add(vendorItemTypeValue);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["VendorItemId"] = new SelectList(_context.VendorItems, "Id", "Id", vendorItemTypeValue.VendorItemId);
            return(View(vendorItemTypeValue));
        }
        public async Task <IActionResult> Create([Bind("Id,Title,Latitude,Longitude,Location,PhoneNumber,HtmlDescription,Address,Email,IsFeatured,Thumb,Categories,Website,Facebook,Instagram")] VendorItemViewModel vendorItemViewModel)
        {
            if (ModelState.IsValid)
            {
                string filename = "";
                if (vendorItemViewModel.Thumb != null && vendorItemViewModel.Thumb.Length > 0)
                {
                    filename = Guid.NewGuid().ToString().Substring(4) + vendorItemViewModel.Thumb.FileName;
                    UploadFile(vendorItemViewModel.Thumb, filename);
                }
                string userId = "";
                if (!string.IsNullOrEmpty(Request.Form["User"]))
                {
                    userId = Request.Form["User"];
                }
                else
                {
                    userId = _userManager.GetUserId(User);
                }
                var        user = _context.Users.Find(userId);
                VendorItem row  = new VendorItem {
                    Thumb = filename, MediaType = vendorItemViewModel.MediaType, Address = vendorItemViewModel.Address, Country = vendorItemViewModel.Country, Email = vendorItemViewModel.Email, HtmlDescription = vendorItemViewModel.HtmlDescription, IsFeatured = vendorItemViewModel.IsFeatured, Latitude = vendorItemViewModel.Latitude, Longitude = vendorItemViewModel.Longitude, Location = vendorItemViewModel.Location, PhoneNumber = vendorItemViewModel.PhoneNumber, Title = vendorItemViewModel.Title, UserId = user.Id, Website = vendorItemViewModel.Website, Facebook = vendorItemViewModel.Facebook, Instagram = vendorItemViewModel.Instagram
                };
                string[] catIds = Request.Form["Categories"].ToString().Split(',');

                var dbcats = _context.VendorCategories.Where(x => catIds.Contains(x.Id.ToString())).ToList();
                foreach (var dbcat in dbcats)
                {
                    _context.VendorItemCategories.Add(new VendorItemCategory {
                        VendorCategory = dbcat, VendorItem = row
                    });
                }
                var taxonomies = _context.VendorTypes.Include(x => x.VendorTypeValues);
                foreach (var tax in taxonomies)
                {
                    string[] valueIds = Request.Form[tax.Id.ToString()].ToString().Split(',');

                    var dbvalues = _context.VendorTypeValues.Where(x => valueIds.Contains(x.Id.ToString())).ToList();
                    foreach (var dbcat in dbvalues)
                    {
                        _context.VendorItemTypeValues.Add(new VendorItemTypeValue {
                            VendorTypeValue = dbcat, VendorItem = row
                        });
                    }
                }
                _context.Add(row);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(vendorItemViewModel));
        }
Ejemplo n.º 22
0
        public async Task <IActionResult> Create([Bind("Id,Title,VendorCategoryId")] VendorType vendorType)
        {
            if (ModelState.IsValid)
            {
                var catId = int.Parse(Request.Form["VendorCategoryId"]);
                var cat   = _context.VendorCategories.Find(catId);
                vendorType.VendorCategory = cat;
                _context.Add(vendorType);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewBag.Categories = new SelectList(_context.VendorCategories, "Id", "Title");
            return(View(vendorType));
        }
Ejemplo n.º 23
0
        public async Task <IActionResult> AddToBasket(int ItemId, int Quantity)
        {
            var user = await _userManager.GetUserAsync(User);

            var offer = _context.Offers.Where(x => x.Id == ItemId).SingleOrDefault();

            var order = _context.Orders.Where(x => x.Users == user && x.OrderStatus == OrderStatus.Pending_Payment).OrderByDescending(x => x.Id).FirstOrDefault();

            if (order == null)
            {
                var    refnumber = Get8Digits();
                string requestId = Guid.NewGuid().ToString().Replace("-", "");
                order = new Order {
                    OrderStatus = OrderStatus.Pending_Payment, Users = user, ReferenceNumber = refnumber, TransactionUUID = requestId
                };
                _context.Orders.Add(order);
            }
            var basket = _context.BasketItems.Where(x => x.Offers == offer && x.Order == order).FirstOrDefault();

            if (basket == null)
            {
                decimal total = (decimal)(offer.Price * Quantity);
                if (offer.SaleFromDate <= DateTime.Now && offer.SaleToDate >= DateTime.Now)
                {
                    total = (decimal)((offer.SalePrice != null || offer.SalePrice != 0) ? offer.SalePrice * Quantity : offer.Price * Quantity);
                }
                basket = new BasketItems {
                    Offers = offer, Quantity = Quantity, TotalPrice = total, Order = order
                };
                _context.BasketItems.Add(basket);
            }
            else
            {
                basket.Quantity += 1;
                decimal total = (decimal)(offer.Price * basket.Quantity);
                if (offer.SaleFromDate <= DateTime.Now && offer.SaleToDate >= DateTime.Now)
                {
                    total = (decimal)((offer.SalePrice != null || offer.SalePrice != 0) ? offer.SalePrice * basket.Quantity : offer.Price * basket.Quantity);
                }
                basket.TotalPrice = total;
            }
            order.Total += basket.TotalPrice;


            await _context.SaveChangesAsync();

            return(View("success"));
        }
Ejemplo n.º 24
0
        public async Task <IActionResult> PostEvents([FromBody] EventsViewModel events)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            string filename = "";

            if (events.Image != null && events.Image.Length > 0)
            {
                filename = events.Image.FileName;
                UploadFile(events.Image, filename);
            }
            var row = _context.Events.Where(x => x.UserId == events.UserId).FirstOrDefault();

            if (row == null)
            {
                row = new Events {
                    Date = events.Date, Description = events.Description, Title = events.Title, UserId = events.UserId, Image = filename, IsPrivate = events.IsPrivate
                };
                _context.Events.Add(row);
            }
            else
            {
                row.Date        = events.Date;
                row.Description = events.Description;
                row.Title       = events.Title;
                row.Image       = filename;
                row.IsPrivate   = events.IsPrivate;
            }
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetEvents", new { id = events.Id }, events));
        }
Ejemplo n.º 25
0
        public async Task <IActionResult> Create([Bind("Id,Image,Title,Description")] homeTipsViewModel homeTipsViewModel)
        {
            if (ModelState.IsValid)
            {
                string filename = Guid.NewGuid().ToString().Substring(4) + homeTipsViewModel.Image.FileName;
                UploadFile(homeTipsViewModel.Image, filename);
                HomeTips homeTips = new HomeTips {
                    Media = filename, MediaType = homeTipsViewModel.MediaType, Description = homeTipsViewModel.Description, Title = homeTipsViewModel.Title, Image = filename
                };
                _context.Add(homeTips);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(homeTipsViewModel));
        }
        public async Task <IActionResult> Create([Bind("Id,Media,MediaType")] HomeSliderViewModel homeSliderViewModel)
        {
            if (ModelState.IsValid)
            {
                string filename = Guid.NewGuid().ToString().Substring(4) + homeSliderViewModel.Media.FileName;
                UploadFile(homeSliderViewModel.Media, filename);
                HomeSlider homeSlider = new HomeSlider {
                    Media = filename, MediaType = homeSliderViewModel.MediaType
                };
                _context.Add(homeSlider);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(homeSliderViewModel));
        }
        public async Task <IActionResult> Create([Bind("Id,Title,Address,PhoneNumber,Latitude,Longitude,VendorItem")] VendorBranches vendorBranches, int itemId)
        {
            if (ModelState.IsValid)
            {
                vendorBranches.VendorItemId = itemId;
                _context.Add(vendorBranches);
                await _context.SaveChangesAsync();

                var parms = new Dictionary <string, string>
                {
                    { "itemId", itemId.ToString() }
                };
                return(RedirectToAction(nameof(Index), parms));
            }

            return(View(vendorBranches));
        }
Ejemplo n.º 28
0
        public async Task <IActionResult> Create([Bind("Id,Title")] VendorTypeValue vendorTypeValue, int typeId)
        {
            if (ModelState.IsValid)
            {
                var vendortype = _context.VendorTypes.Find(typeId);
                vendorTypeValue.VendorType = vendortype;
                _context.Add(vendorTypeValue);
                await _context.SaveChangesAsync();

                var parms = new Dictionary <string, string>
                {
                    { "typeId", typeId.ToString() }
                };
                return(RedirectToAction(nameof(Index), parms));
            }
            return(View(vendorTypeValue));
        }
Ejemplo n.º 29
0
        public async Task <IActionResult> Create([Bind("Id,FirstName,LastName,Age,Gender,Address,City,Country,UserType,CreationDate,Image,PhoneNumber,Email,Username")] UsersViewModel users)
        {
            if (ModelState.IsValid)
            {
                string filename = "";
                if (users.Image != null)
                {
                    filename = Guid.NewGuid().ToString().Substring(4) + users.Image.FileName;
                    UploadFile(users.Image, filename);
                }
                Users user = new Users {
                    Id = users.Id, FirstName = users.FirstName, LastName = users.LastName, Age = users.Age, Gender = users.Gender, Address = users.Address, City = users.City, Country = users.Country, UserType = users.UserType, CreationDate = users.CreationDate, Image = filename, UserName = users.Username, PhoneNumber = users.PhoneNumber, Email = users.Email
                };
                _context.Add(user);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(users));
        }
        public async Task <IActionResult> Create([Bind("Id,Image,Title")] BlogCategoryViewModel blogCategoryViewModel)
        {
            if (ModelState.IsValid)
            {
                string filename = "";
                if (blogCategoryViewModel.Image != null)
                {
                    filename = Guid.NewGuid().ToString().Substring(4) + blogCategoryViewModel.Image.FileName;
                    UploadFile(blogCategoryViewModel.Image, filename);
                }
                BlogCategory category = new BlogCategory {
                    Image = filename, Title = blogCategoryViewModel.Title
                };
                _context.Add(category);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(blogCategoryViewModel));
        }