Beispiel #1
0
        public async Task <IActionResult> ShipownerPostShipCargoRelation([FromBody] ShipCargoRelation shipCargoRelation)
        {
            var userid = HttpContext.User.Identity.Name;

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            if (shipCargoRelation != null && userid != null && shipCargoRelation.FixedFreight != 0 && shipCargoRelation.ShipId != 0 && shipCargoRelation.Commission != 0)
            {
                shipCargoRelation.DateCreated  = System.DateTime.Now;
                shipCargoRelation.ShipUserId   = userid;
                shipCargoRelation.AcceptorRole = "Charterer";
                shipCargoRelation.IsApproved1  = false;
                _context.ShipCargoRelations.Add(shipCargoRelation);
                await _context.SaveChangesAsync();
            }
            else
            {
                return(BadRequest("Please Fill all required Fields"));
            }


            return(CreatedAtAction("GetShipCargoRelation", new { id = shipCargoRelation.Id }, shipCargoRelation));
        }
Beispiel #2
0
        public async Task <IActionResult> PutShipCargoRelation([FromRoute] long id, [FromBody] ShipCargoRelation shipCargoRelation)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(NoContent());
        }