Exemple #1
0
        public async Task <IActionResult> Edit(int id, [Bind("LocalizationId,PostalCode,PlaceName,Province")] Localization localization)
        {
            if (id != localization.LocalizationId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(localization);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!LocalizationExists(localization.LocalizationId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(localization));
        }
Exemple #2
0
        public async Task <IActionResult> Edit(int id, [Bind("BookConditionId,Condition")] BookCondition bookCondition)
        {
            if (id != bookCondition.BookConditionId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(bookCondition);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BookConditionExists(bookCondition.BookConditionId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(bookCondition));
        }
Exemple #3
0
        public async Task <IActionResult> Edit(int id, [Bind("UserId,UserName,FirstName,MiddleName,LastName,UserType,Address,Number,AddressComplement,Age,Email,Phone,Creditcard,CreditcardSecurityCode,CredicardExpirationDate,LocalizationId,InstitutionBranchId")] User user)
        {
            if (id != user.UserId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(user);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!UserExists(user.UserId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["InstitutionBranchId"] = new SelectList(_context.InstitutionBranch, "InstitutionBranchId", "InstitutionBranchName", user.InstitutionBranchId);
            ViewData["LocalizationId"]      = new SelectList(_context.Localization, "LocalizationId", "PlaceName", user.LocalizationId);
            return(View(user));
        }
        public async Task <IActionResult> Edit(int id, [Bind("InstitutionBranchId,InstitutionBranchName,InstitutionId")] InstitutionBranch institutionBranch)
        {
            if (id != institutionBranch.InstitutionBranchId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(institutionBranch);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!InstitutionBranchExists(institutionBranch.InstitutionBranchId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["InstitutionId"] = new SelectList(_context.Institution, "InstitutionId", "InstitutionName", institutionBranch.InstitutionId);
            return(View(institutionBranch));
        }
Exemple #5
0
        public async Task <IActionResult> Edit(int id, [Bind("ClaimMediationId,Description,Action,ClaimId")] ClaimMediation claimMediation)
        {
            if (id != claimMediation.ClaimMediationId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(claimMediation);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ClaimMediationExists(claimMediation.ClaimMediationId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ClaimId"] = new SelectList(_context.Claim, "ClaimId", "Description", claimMediation.ClaimId);
            return(View(claimMediation));
        }
Exemple #6
0
        public async Task <IActionResult> Edit(int id, [Bind("CourseId,CourseName,StudyAreaId,InstitutionId")] Course course)
        {
            if (id != course.CourseId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(course);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CourseExists(course.CourseId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["InstitutionId"] = new SelectList(_context.Institution, "InstitutionId", "InstitutionName", course.InstitutionId);
            ViewData["StudyAreaId"]   = new SelectList(_context.StudyArea, "StudyAreaId", "StudyAreaName", course.StudyAreaId);
            return(View(course));
        }
Exemple #7
0
        public async Task <IActionResult> Edit(int id, [Bind("BookId,Title,Description,ISBN,Publisher,Edition,Quantity,Price,Visualizations,QuantitySold,Blocked,IsWaitList,CreationDate,BookConditionId,StudyAreaId,SellerId")] Book book)
        {
            if (id != book.BookId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(book);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BookExists(book.BookId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BookConditionId"] = new SelectList(_context.BookCondition, "BookConditionId", "Condition", book.BookConditionId);
            ViewData["SellerId"]        = new SelectList(_context.Set <Seller>(), "UserId", "Discriminator", book.SellerId);
            ViewData["StudyAreaId"]     = new SelectList(_context.StudyArea, "StudyAreaId", "StudyAreaName", book.StudyAreaId);
            return(View(book));
        }
        public async Task <IActionResult> Edit(int id, [Bind("StudyAreaId,StudyAreaName")] StudyArea studyArea)
        {
            if (id != studyArea.StudyAreaId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(studyArea);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!StudyAreaExists(studyArea.StudyAreaId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(studyArea));
        }
        public async Task <IActionResult> Edit(int id, [Bind("CustomerId,FullName,Email,PostCode,CodeNumber,Message")] CustomerService customerService)
        {
            if (id != customerService.CustomerId)
            {
                return(NotFound());
            }

            //  string LogedUser = this.User.Identity.Name;
            //  customerService.Email = LogedUser;
            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(customerService);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CustomerServiceExists(customerService.CustomerId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(customerService));
        }
Exemple #10
0
        public async Task <IActionResult> Edit(int id, [Bind("ClaimId,Description,Status,OrderId,UserId")] Claim claim)
        {
            if (id != claim.ClaimId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(claim);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ClaimExists(claim.ClaimId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["OrderId"] = new SelectList(_context.Order, "OrderId", "OrderId", claim.OrderId);
            ViewData["UserId"]  = new SelectList(_context.User, "UserId", "Discriminator", claim.UserId);
            return(View(claim));
        }
Exemple #11
0
        public async Task <IActionResult> Edit(int id, [Bind("OrderId,Quantity,Price,PaymentForm,CreationDate,PaymentDate,ReleaseDate,CancelationDate,CanfirmationDate,Status,IsConfirmedByBuyer,BookId,BuyerId,SellerId")] Order order)
        {
            if (id != order.OrderId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(order);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!OrderExists(order.OrderId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BookId"]   = new SelectList(_context.Book, "BookId", "ISBN", order.BookId);
            ViewData["BuyerId"]  = new SelectList(_context.Set <Buyer>(), "UserId", "Discriminator", order.BuyerId);
            ViewData["SellerId"] = new SelectList(_context.Set <Seller>(), "UserId", "Discriminator", order.SellerId);
            return(View(order));
        }
Exemple #12
0
        //public async Task<IActionResult> BuyIt([Bind("OrderId,Quantity,Price,PaymentForm,CreationDate,PaymentDate,ReleaseDate,CancelationDate,CanfirmationDate,Status,IsConfirmedByBuyer,BookId,UserId,SellerId,Seller")] Order order)
        public async Task <IActionResult> BuyIt([Bind("OrderId,Quantity,Price,PaymentForm,CreationDate,PaymentDate,ReleaseDate,CancelationDate,CanfirmationDate,Status,IsConfirmedByBuyer,BookId,UserId,SellerId,Seller")] Order order)
        {
            if (ModelState.IsValid)
            {
                var order2 = _context.Add(order);
                await _context.SaveChangesAsync();

                Book book = (from b in _context.Book
                             where b.BookId == order.BookId
                             select b).First();
                book.Quantity     -= order.Quantity;
                book.QuantitySold += order.Quantity;

                _context.Update(book);
                await _context.SaveChangesAsync();

                return(RedirectToAction("SuccessfulTransactionMsg", order));
            }
            ViewData["BookId"] = new SelectList(_context.Book, "BookId", "ISBN", order.BookId);
            ViewData["UserId"] = new SelectList(_context.User, "UserId", "CreditcardName", order.UserId);
            return(View(order));
        }
Exemple #13
0
        public async Task <IActionResult> Edit(int id, int BookId, string Title, string Description, string ISBN, string Publisher
                                               , int Edition, int Quantity, double Price, int BookConditionId, int StudyAreaId,
                                               IFormFile PhotoFileName)
        //public async Task<IActionResult> Edit(int id, BookId,PhotoFileName,Title,Description,ISBN,Publisher,Edition,Quantity,Price,Visualizations,QuantitySold,Blocked,IsWaitList,CreationDate,BookConditionId,StudyAreaId,UserId)
        //
        {
            long size = 0;

            Book book = new Book
            {
                BookId          = BookId,
                Blocked         = false,
                BookConditionId = BookConditionId,
                CreationDate    = DateTime.Now,
                Description     = Description,
                Edition         = Edition,
                ISBN            = ISBN,
                IsWaitList      = false,
                Price           = Price,
                Publisher       = Publisher,
                Quantity        = Quantity,
                QuantitySold    = 0,
                StudyAreaId     = StudyAreaId,
                Title           = Title
            };

            string LogedUser = this.User.Identity.Name;
            var    user      = (from s in _context.User where s.UserName == LogedUser select s.UserId).ToList();
            int    UserId    = user[0];

            if (UserId > 0)
            {
                book.UserId = UserId;
                if (PhotoFileName != null)
                {
                    //using (MemoryStream ms = new MemoryStream())
                    //{
                    //    await PhotoFileName.CopyToAsync(ms);
                    //    book.PhotoFileName = ms.ToArray();
                    //}
                    MemoryStream ms = new MemoryStream();
                    await PhotoFileName.CopyToAsync(ms);

                    book.PhotoFileName = ms.ToArray();
                    size = (PhotoFileName.Length / 1024);
                }



                if (id != book.BookId)
                {
                    return(NotFound());
                }

                if (ModelState.IsValid && size <= 2048)
                {
                    try
                    {
                        if (BookExists(book.BookId) && PhotoFileName == null)
                        {
                            var bk = (from b in _context.Book where b.BookId == book.BookId select b.PhotoFileName).ToArray();
                            book.PhotoFileName = bk[0];
                        }

                        _context.Update(book);
                        await _context.SaveChangesAsync();
                    }
                    catch (DbUpdateConcurrencyException)
                    {
                        if (!BookExists(book.BookId))
                        {
                            return(NotFound());
                        }
                        else
                        {
                            throw;
                        }
                    }
                    return(RedirectToAction(nameof(Index)));
                }
            }
            ViewData["BookConditionId"] = new SelectList(_context.BookCondition, "BookConditionId", "Condition", book.BookConditionId);
            ViewData["StudyAreaId"]     = new SelectList(_context.StudyArea, "StudyAreaId", "StudyAreaName", book.StudyAreaId);
            ViewData["UserId"]          = new SelectList(_context.User, "UserId", "CreditcardName", book.UserId);
            return(View(book));
        }