Example #1
0
        // [Route("UpdateInternalHistoryDTOy/{ID:int}")]
        public IActionResult UpdateInternalHistoryDTO(int ID, [FromBody] InternalHistoryDTO InternalHistoryDTO)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            if (InternalHistoryDTO == null)
            {
                return(BadRequest());
            }

            var objInternalHistoryDTO = _choiceRepoistory.GetById <InternalHistory>(c => c.InternalHistoryId == ID);

            if (objInternalHistoryDTO == null)
            {
                return(BadRequest());
            }


            objInternalHistoryDTO.InternalHistoryId = InternalHistoryDTO.InternalHistoryId;
            objInternalHistoryDTO.History           = InternalHistoryDTO.History;
            objInternalHistoryDTO.BookingId         = InternalHistoryDTO.BookingId;
            objInternalHistoryDTO.CreatedDate       = InternalHistoryDTO.CreatedDate;
            objInternalHistoryDTO.CreatedBy         = InternalHistoryDTO.CreatedBy;
            objInternalHistoryDTO.SharepointId      = InternalHistoryDTO.SharepointId;
            _choiceRepoistory.Attach(objInternalHistoryDTO);
            _choiceRepoistory.Complete();
            return(NoContent());
        }
Example #2
0
        public ActionResult InternalHistory([FromBody] InternalHistoryDTO InternalHistoryDTO)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            if (InternalHistoryDTO == null)
            {
                return(BadRequest());
            }

            var checkInternalHistoryDTOIdinDb = _choiceRepoistory.GetInternalHistory().Find(c => c.InternalHistoryId == InternalHistoryDTO.InternalHistoryId);

            if (checkInternalHistoryDTOIdinDb != null)
            {
                return(BadRequest());
            }

            InternalHistory newlyInternalHistoryDTO = new InternalHistory()
            {
                InternalHistoryId = InternalHistoryDTO.InternalHistoryId,
                History           = InternalHistoryDTO.History,
                BookingId         = InternalHistoryDTO.BookingId,
                CreatedDate       = InternalHistoryDTO.CreatedDate,
                CreatedBy         = InternalHistoryDTO.CreatedBy,
                SharepointId      = InternalHistoryDTO.SharepointId,
            };

            _choiceRepoistory.SetInternalHistory(newlyInternalHistoryDTO);
            _choiceRepoistory.Complete();
            return(CreatedAtRoute("GetInternalHistorybyID", new { newlyInternalHistoryDTO.InternalHistoryId }, newlyInternalHistoryDTO));
        }