예제 #1
0
        public async Task <IActionResult> Edit(string id, [Bind("vendorLineId,jobTitle,vendorId,firstName,lastName,middleName,nickName,gender,salutation,mobilePhone,officePhone,fax,personalEmail,workEmail,createdAt")] VendorLine vendorLine)
        {
            if (id != vendorLine.vendorLineId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(vendorLine);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!VendorLineExists(vendorLine.vendorLineId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["vendorId"] = new SelectList(_context.Vendor, "vendorId", "vendorId", vendorLine.vendorId);
            return(View(vendorLine));
        }
예제 #2
0
        public async Task <IActionResult> Create([Bind("vendorLineId,jobTitle,vendorId,firstName,lastName,middleName,nickName,gender,salutation,mobilePhone,officePhone,fax,personalEmail,workEmail,createdAt")] VendorLine vendorLine)
        {
            if (ModelState.IsValid)
            {
                _context.Add(vendorLine);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["vendorId"] = new SelectList(_context.Vendor, "vendorId", "vendorId", vendorLine.vendorId);
            return(View(vendorLine));
        }
예제 #3
0
        // GET: VendorLine/Create
        public IActionResult Create(string masterid, string id)
        {
            var check    = _context.VendorLine.SingleOrDefault(m => m.vendorLineId == id);
            var selected = _context.Vendor.SingleOrDefault(m => m.vendorId == masterid);

            ViewData["vendorId"] = new SelectList(_context.Vendor, "vendorId", "vendorId");
            if (check == null)
            {
                VendorLine objline = new VendorLine();
                objline.vendor   = selected;
                objline.vendorId = masterid;
                return(View(objline));
            }
            else
            {
                return(View(check));
            }
        }
예제 #4
0
        public async Task <IActionResult> PostVendorLine([FromBody] VendorLine vendorLine)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (vendorLine.vendorLineId == string.Empty)
            {
                vendorLine.vendorLineId = Guid.NewGuid().ToString();
                _context.VendorLine.Add(vendorLine);
                await _context.SaveChangesAsync();

                return(Json(new { success = true, message = "Add new data success." }));
            }
            else
            {
                _context.Update(vendorLine);
                await _context.SaveChangesAsync();

                return(Json(new { success = true, message = "Edit data success." }));
            }
        }
예제 #5
0
        public async Task <IActionResult> PostVendorLine([FromBody] VendorLine vendorLine)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (vendorLine.vendorLineId == string.Empty)
            {
                vendorLine.vendorLineId = Guid.NewGuid().ToString();
                _context.VendorLine.Add(vendorLine);
                await _context.SaveChangesAsync();

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

                return(Json(new { success = true, message = "Η Επεξεργασία της επαφής " + vendorLine.firstName + " " + vendorLine.lastName + " έγινε με επιτυχία." }));
            }
        }