Exemple #1
0
        public async Task <IActionResult> Edit(string id, [Bind("CatalogLineId,CatalogId,Discount,ProductId,createdAt,EndDate")] CatalogLine catalogLine)
        {
            if (id != catalogLine.CatalogLineId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(catalogLine);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CatalogLineExists(catalogLine.CatalogLineId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["productId"] = new SelectList(_context.Product, "productId", "productCode", catalogLine.ProductId);
            ViewData["catalogId"] = new SelectList(_context.Catalog, "CatalogId", "CatalogId", catalogLine.CatalogId);
            return(View(catalogLine));
        }
Exemple #2
0
        public async Task <IActionResult> Create([Bind("CatalogLineId,CatalogId,Discount,ProductId,createdAt,EndDate")] CatalogLine catalogLine)
        {
            if (ModelState.IsValid)
            {
                _context.Add(catalogLine);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["productId"] = new SelectList(_context.Product, "productId", "productCode", catalogLine.ProductId);
            ViewData["catalogId"] = new SelectList(_context.Catalog, "CatalogId", "CatalogId", catalogLine.CatalogId);
            return(View(catalogLine));
        }
Exemple #3
0
        // GET: CatalogLine/Create
        public IActionResult Create(string masterid, string id)
        {
            var check    = _context.CatalogLine.SingleOrDefault(m => m.CatalogLineId == id);
            var selected = _context.Catalog.SingleOrDefault(m => m.CatalogId == masterid);

            ViewData["productId"] = new SelectList(_context.Product, "productId", "productCode");
            ViewData["catalogId"] = new SelectList(_context.Catalog, "CatalogId", "CatalogId");
            if (check == null)
            {
                CatalogLine objline = new CatalogLine
                {
                    Catalog   = selected,
                    CatalogId = masterid
                };
                return(View(objline));
            }
            else
            {
                return(View(check));
            }
        }
Exemple #4
0
        public async Task <IActionResult> PostCatalogLine([FromBody] CatalogLine catalogLine)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (string.IsNullOrEmpty(catalogLine.CatalogLineId))
            {
                catalogLine.CatalogLineId = Guid.NewGuid().ToString();
                _context.CatalogLine.Add(catalogLine);
                await _context.SaveChangesAsync();

                return(Json(new { success = true, message = "Η Προσθήκη στοιχείου Έκπτωσης, έγινε με επιτυχία." }));
            }
            else
            {
                _context.Update(catalogLine);
                await _context.SaveChangesAsync();

                return(Json(new { success = true, message = "Η Επεξεργασία στοιχείου Έκπτωσης, έγινε με επιτυχία." }));
            }
        }