Example #1
0
    public async Task <IActionResult> PutBranch([FromRoute] int id, [FromBody] Branch branch)
    {
        if (!ModelState.IsValid)
        {
            return(BadRequest(ModelState));
        }

        if (id != branch.Id)
        {
            return(BadRequest());
        }

        _context.Entry(branch).State = EntityState.Modified;

        try
        {
            await _context.SaveChangesAsync();
        }
        catch (DbUpdateConcurrencyException)
        {
            if (!BranchExists(id))
            {
                return(NotFound());
            }
            else
            {
                throw;
            }
        }

        return(NoContent());
    }
Example #2
0
        public async Task <IActionResult> Create([Bind("Id,BranchName,BranchEmail,PhoneNumber,PhysicalAddress,Manager")] Branch branch)
        {
            if (ModelState.IsValid)
            {
                _context.Add(branch);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(branch));
        }
Example #3
0
        public async Task <IActionResult> Create([Bind("Id,CustomerName,CustomerAddress,CustomerNumber,TotalWeight,NoParcels,TotalValue")] Waybill waybill)
        {
            if (ModelState.IsValid)
            {
                _context.Add(waybill);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(waybill));
        }
        public async Task <IActionResult> Create([Bind("Id,Make,Model,Mileage,Description")] Vehicle vehicle)
        {
            if (ModelState.IsValid)
            {
                _context.Add(vehicle);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(vehicle));
        }