Exemplo n.º 1
0
        public IActionResult UpdateProduct(FarmerProduct farmerProduct)
        {
            var id = new int[] { 1 };

            _productService.Update(farmerProduct, id);
            return(Ok());
        }
Exemplo n.º 2
0
        public async Task <IActionResult> UserCreateDeclare(ProductModel model, IFormFile file)
        {
            List <DeclareModel> customerInformation = null;
            var declare = new FarmerProduct()
            {
                UserName          = model.UserName,
                UserSurname       = model.UserSurname,
                UserEMail         = model.UserEMail,
                UserPhoneNumber   = model.UserPhoneNumber,
                Name              = model.Name,
                Gender            = model.Gender,
                Neighborhood      = model.Neighborhood,
                Price             = model.Price,
                PermissionToSell  = false,
                Guarantee         = model.Guarantee,
                Description       = model.Description,
                Country           = model.Country,
                City              = model.City,
                Situation         = model.Situation,
                AnimalAge         = model.AnimalAge,
                AnnouncementDate  = model.AnnouncementDate,
                FarmerDeclareType = model.FarmerDeclareType,
                StockQty          = model.StockQty,
                Swap              = model.Swap,
                Title             = model.Title,
                UserId            = model.UserId
            };

            if (file != null)
            {
                var incerrectImage = Path.GetExtension(file.FileName);
                if (incerrectImage == ".jpg" || incerrectImage == ".jpeg" || incerrectImage == ".png" || incerrectImage == ".bmp" || incerrectImage == ".gif" || incerrectImage == ".tiff")
                {
                    Random rastgele = new Random();
                    string harfler  = "ABCÇDEFGĞHIİJKLMNOÖPRSŞTUÜVYZabcçdefgğhıijklmnoöprsştuüvyz";
                    string uret     = "";
                    for (int i = 0; i < 6; i++)
                    {
                        uret += harfler[rastgele.Next(harfler.Length)];
                    }

                    declare.ImageUrl = uret + ".jpg";
                    var path = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot\\img\\ProductImages", uret + ".jpg");

                    using (var stream = new FileStream(path, FileMode.Create))
                    {
                        await file.CopyToAsync(stream).ConfigureAwait(false);
                    }

                    _productService.Create(declare);
                    return(Redirect("/User/UserAccount"));
                }
                else
                {
                    ViewBag.IncerrectImageExtension = "Hata !!! Desteklenmeyen dosya uzantısı yüklemeye çalıştınız lütfen yükleyeceginiz dosyanın uzantısının \"jpg, png, jpeg, tiff, bmp\" oldugundan emin olunuz...";
                    customerInformation             = new List <DeclareModel>();
                }
            }
            return(View(customerInformation));
        }
Exemplo n.º 3
0
 public void Update(FarmerProduct entity) =>
 _productRepository.Update(entity);
Exemplo n.º 4
0
 public void Update(FarmerProduct entity, int[] categoryIds) =>
 _productRepository.Update(entity, categoryIds);
Exemplo n.º 5
0
 public void Delete(FarmerProduct entity) =>
 _productRepository.Delete(entity);
Exemplo n.º 6
0
 public void Create(FarmerProduct entity) =>
 _productRepository.Create(entity);