Ejemplo n.º 1
0
        public IActionResult  Post([FromBody] EOPTypeCreationDTO EOPType)
        {
            try{
                if (EOPType == null)
                {
                    //_logger.LogError("Owner object sent from client is null.");
                    return(BadRequest("Owner object is null"));
                }

                if (!ModelState.IsValid)
                {
                    //_logger.LogError("Invalid owner object sent from client.");
                    return(BadRequest("Invalid model object"));
                }

                var Entity = _mapper.Map <EOPType>(EOPType);

                _eOPTypeService.Create(Entity);

                var EntityToReturn = _mapper.Map <EOPTypeDto>(Entity);

                return(CreatedAtRoute("GetById", new { id = EntityToReturn.Id }, EntityToReturn));
            }
            catch (Exception ex)
            {
                //_logger.LogError($"Something went wrong inside CreateOwner action: {ex.Message}");
                return(StatusCode(500, "Internal server error" + ex.ToString()));
            }
        }
Ejemplo n.º 2
0
        public static void EOPTypeSeed(IEOPTypeService EOPTypeservice)
        {
            var types = new List <EOPType>
            {
                new EOPType {
                    Id = 1, Name = "Product"
                },
                new EOPType {
                    Id = 2, Name = "Mechanization"
                },
                new EOPType {
                    Id = 3, Name = "Farmer Equity Contribution"
                },
            };


            foreach (var type in types)
            {
                EOPTypeservice.Create(type).Wait();
            }
        }