Ejemplo n.º 1
0
        public async Task <IActionResult> Edit(long id, [Bind("ItemsPk,ItemId,Barcode,AvgCost,LastCost,LastPurchasedDate,Qty,Starred,MakeId,ModelId,YearId,Vin,SalePrice,Discount,NetPrice,Active,Photo,More,LotNo,SupplierCarNo,RefNo,Sold")] Items items)
        {
            if (id != items.ItemId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(items);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ItemsExists(items.ItemId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["MakeId"]  = new SelectList(_context.Makes, "MakeId", "MakeName", items.MakeId);
            ViewData["ModelId"] = new SelectList(_context.Models, "ModelId", "ModelName", items.ModelId);
            ViewData["YearId"]  = new SelectList(_context.Years, "YearId", "YearId", items.YearId);
            return(View(items));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,TypeId")] Banks banks)
        {
            if (id != banks.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(banks);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BanksExists(banks.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(banks));
        }
Ejemplo n.º 3
0
        public async Task<IActionResult> Edit(int id, [Bind("Id,Name")] Parts parts)
        {
            if (id != parts.Id)
            {
                return NotFound();
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(parts);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PartsExists(parts.Id))
                    {
                        return NotFound();
                    }
                    else
                    {
                        throw;
                    }
                }
                return RedirectToAction(nameof(Index));
            }
            return View(parts);
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> Edit(long id, [Bind("PartId,ItemId,PartName,Qty,Barcode,AvgCost,LastCost,SalePrice,More,Active,Starred,Deleted,LastPurchasedDate,AddDate,PartId1")] ItemParts itemParts)
        {
            if (id != itemParts.PartId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    itemParts.AvgCost = itemParts.Qty * itemParts.SalePrice;
                    _context.Update(itemParts);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ItemPartsExists(itemParts.PartId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index), new { id = itemParts.ItemId }));
            }
            ViewData["ItemId"]  = new SelectList(_context.Items, "ItemId", "ItemId", itemParts.ItemId);
            ViewData["PartId1"] = new SelectList(_context.Parts, "Id", "Name", itemParts.PartId1);
            return(View(itemParts));
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> Edit(int id, [Bind("YearId")] Years years)
        {
            if (id != years.YearId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(years);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!YearsExists(years.YearId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(years));
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> Edit(int id, [Bind("ModelId,MakeId,ModelName")] Core.StoreModels.Models models)
        {
            if (id != models.ModelId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(models);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ModelsExists(models.ModelId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["MakeId"] = new SelectList(_context.Makes, "MakeId", "MakeName", models.MakeId);
            return(View(models));
        }
Ejemplo n.º 7
0
        public async Task <IActionResult> Edit(int id, [Bind("AccountId,AccountTypeId,Title,BalanceIn,BalanceOut,Phone,Address,Category,Code,More")] Accounts accounts)
        {
            if (id != accounts.AccountId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(accounts);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AccountsExists(accounts.AccountId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(accounts));
        }
Ejemplo n.º 8
0
        public async Task <IActionResult> Edit(int id, [Bind("MakeId,MakeName")] Makes makes)
        {
            if (id != makes.MakeId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(makes);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MakesExists(makes.MakeId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(makes));
        }
Ejemplo n.º 9
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,GroupName,Title,Value,Active")] Settings settings)
        {
            if (id != settings.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(settings);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SettingsExists(settings.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(settings));
        }
Ejemplo n.º 10
0
        //[ValidateAntiForgeryToken]
        public async Task <ActionResult <string> > Save([FromBody] Invoices invoice)
        {
            try
            {
                if (ModelState.IsValid)  //if (invoices != null)
                {
                    // set ip & user id
                    var exitsBefore = await _context.Invoices.FindAsync(invoice.Id);

                    if (exitsBefore != null)
                    { // update
                        exitsBefore.InvoiceNo     = invoice.InvoiceNo;
                        exitsBefore.Notes         = invoice.Notes;
                        exitsBefore.NetAmount     = invoice.NetAmount;
                        exitsBefore.Discount      = invoice.Discount;
                        exitsBefore.TotalAmount   = invoice.TotalAmount;
                        exitsBefore.AccountId     = invoice.AccountId;
                        exitsBefore.InvoiceTypeId = invoice.InvoiceTypeId;
                        exitsBefore.AddDate       = invoice.AddDate;
                        _context.Update(exitsBefore);
                        _context.UpdateRange(invoice.InvoiceDetails);
                    }
                    else // insert
                    {
                        _context.Add(invoice);
                        foreach (var itm in invoice.InvoiceDetails)
                        {
                            itm.InvoiceId = invoice.Id;
                        }
                        _context.AddRange(invoice.InvoiceDetails);
                    }

                    await _context.SaveChangesAsync();

                    return(CreatedAtAction("Result", new { id = invoice.Id, saved = true }));
                }
                else
                {
                    return(CreatedAtAction("Result", new { id = 0, saved = false }));
                }
            }
            catch (Exception ex) { return(CreatedAtAction("Result", new { id = ex.Message, saved = false })); }
        }
Ejemplo n.º 11
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,InvoiceId,Amount,Discount,Tax,Extra,Total,AccountId,PaymentTypeId,OperationId,FromBankId,ToBankId,AddDate,AddTime,RefNo,Notes")] Payments payments)
        {
            if (id != payments.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    payments.AddTime = DateTime.UtcNow;
                    _context.Update(payments);
                    await _context.SaveChangesAsync();

                    // Archive client transactions in case he paying to us (قبض - قبض بشيك).
                    if (payments.AccountId > 0 && (payments.OperationId == (int)PaymentTypesEnum.Credit || payments.OperationId == (int)PaymentTypesEnum.CheckCredit))
                    {
                        await new TransactionsService(_context).ArchiveAccountInvoicesPaymanetsAsync(payments.AccountId);
                    }
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PaymentsExists(payments.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AccountId"]     = new SelectList(_context.Accounts, "AccountId", "Title", payments.AccountId);
            ViewData["FromBankId"]    = new SelectList(_context.Banks, "Id", "Name", payments.FromBankId);
            ViewData["InvoiceId"]     = new SelectList(_context.Invoices, "Id", "InvoiceNo", payments.InvoiceId);
            ViewData["OperationId"]   = new SelectList(_context.Operations, "Id", "Name", payments.OperationId);
            ViewData["PaymentTypeId"] = new SelectList(_context.PaymentTypes, "Id", "Name", payments.PaymentTypeId);
            ViewData["ToBankId"]      = new SelectList(_context.Banks, "Id", "Name", payments.ToBankId);

            return(View(payments));
        }