Example #1
0
        public async Task <IActionResult> PostRequestForQuote([FromBody] RequestForQuote requestforquote)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.RequestForQuote.Add(requestforquote);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (RequestForQuoteExists(requestforquote.QuoteId))
                {
                    return(new StatusCodeResult(StatusCodes.Status409Conflict));
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtAction("GetRequestForQuote", new { id = requestforquote.QuoteId }, requestforquote));
        }
Example #2
0
        public async Task <IActionResult> PutRequestForQuote([FromRoute] int id, [FromBody] RequestForQuote requestforquote)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != requestforquote.QuoteId)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Example #3
0
        public async Task <IActionResult> Create([Bind("QuoteId,ClientName,ClientPhone,ClientEmail,ClientRep,ClientRepContact,ProjectName,ProjectManager,PredStartDate,PredCompletionDate,ProjectDescription")] RequestForQuote requestforquote)
        {
            if (ModelState.IsValid)
            {
                var result = await _context.PostApiCall <RequestForQuote>("RequestForQuotes", requestforquote);

                return(RedirectToAction(nameof(Index)));
            }
            return(View(requestforquote));
        }
Example #4
0
        public async Task <IActionResult> Edit(int id, [Bind("QuoteId, ClientName, ClientPhone, ClientEmail, ClientRep, ClientRepContact, ProjectName, ProjectManager, PredStartDate, PredCompletionDate, ProjectDescription")] RequestForQuote requestforquote)
        {
            if (id != requestforquote.QuoteId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                var result = await _context.PutApiCall <RequestForQuote>(string.Concat("RequestForQuotes", "/", id), requestforquote);

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

            return(View(requestforquote));
        }