Example #1
0
        public async Task <IActionResult> OnPost()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            await _repository.Create(Agent);

            return(RedirectToPage("Index"));
        }
Example #2
0
        public async Task <ActionResult> CreateNewAgent(Agent agent)
        {
            try
            {
                if (agent == null)
                {
                    return(BadRequest());
                }
                var agentCreated = await _repository.Create(agent);

                return(CreatedAtAction(nameof(GetAgent), new { id = agentCreated.AgentId }, agentCreated));
            }
            catch (System.Exception)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError,
                                  "There were error in createing new customer, Please contact your admin!"));
            }
        }