Beispiel #1
0
        public HttpResponseMessage CreateAssetType([FromBody] AssetTypeDTO assetTypeDTO)
        {
            int    newID = _assetService.CreateAssetType(assetTypeDTO);
            string uri   = Url.Link("AssetTypeByIDRoute", new { id = newID });
            // Generate a link to the new campus and set the location header in the response.
            var response = new HttpResponseMessage(HttpStatusCode.Created);

            response.Headers.Location = new System.Uri(uri);
            return(response);
        }
Beispiel #2
0
        public int CreateAssetType(AssetTypeDTO assetTypeDTO)
        {
            using (var scope = new TransactionScope())
            {
                //Get DTO and assign default properties
                var assType = new AssetType();
                assType             = assetTypeDTO.ToEntity();
                assType.CreatedDate = assType.ModifiedDate = System.DateTime.Now;

                //Insert data object
                _unitOfWork.AssetTypeRepository.Insert(assType);
                _unitOfWork.Save();
                scope.Complete();
                return(assType.ID);
            }
        }
        /// <summary>
        /// Converts this instance of <see cref="AssetType"/> to an instance of <see cref="AssetTypeDTO"/>.
        /// </summary>
        /// <param name="entity"><see cref="AssetType"/> to convert.</param>
        public static AssetTypeDTO ToDTO(this AssetType entity)
        {
            if (entity == null)
            {
                return(null);
            }

            var dto = new AssetTypeDTO();

            dto.ID               = entity.ID;
            dto.Name             = entity.Name;
            dto.CreatedByUserID  = entity.CreatedByUserID;
            dto.CreatedDate      = entity.CreatedDate;
            dto.ModifiedByUserID = entity.ModifiedByUserID;
            dto.ModifiedDate     = entity.ModifiedDate;
            entity.OnDTO(dto);

            return(dto);
        }
        /// <summary>
        /// Converts this instance of <see cref="AssetTypeDTO"/> to an instance of <see cref="AssetType"/>.
        /// </summary>
        /// <param name="dto"><see cref="AssetTypeDTO"/> to convert.</param>
        public static AssetType ToEntity(this AssetTypeDTO dto)
        {
            if (dto == null)
            {
                return(null);
            }

            var entity = new AssetType();

            entity.ID               = dto.ID;
            entity.Name             = dto.Name;
            entity.CreatedByUserID  = dto.CreatedByUserID;
            entity.CreatedDate      = dto.CreatedDate;
            entity.ModifiedByUserID = dto.ModifiedByUserID;
            entity.ModifiedDate     = dto.ModifiedDate;
            dto.OnEntity(entity);

            return(entity);
        }
 /// <summary>
 /// Invoked when <see cref="ToEntity"/> operation is about to return.
 /// </summary>
 /// <param name="entity"><see cref="AssetType"/> converted from <see cref="AssetTypeDTO"/>.</param>
 static partial void OnEntity(this AssetTypeDTO dto, AssetType entity);
 /// <summary>
 /// Invoked when <see cref="ToDTO"/> operation is about to return.
 /// </summary>
 /// <param name="dto"><see cref="AssetTypeDTO"/> converted from <see cref="AssetType"/>.</param>
 static partial void OnDTO(this AssetType entity, AssetTypeDTO dto);
 public AssetType Map(AssetTypeDTO dto)
 {
     if (dto == null) return null;
     var assetType = Mapper.Map<AssetTypeDTO, AssetType>(dto);
     return assetType;
 }
 public AssetTypeDTOTest()
 {
     _assetTypeDTO = new AssetTypeDTO {
         Name = "Cell Phone"
     };
 }
Beispiel #9
0
 public bool UpdateAssetType(int assetTypeID, AssetTypeDTO assetTypeDTO)
 {
     throw new NotImplementedException();
 }
 public async Task <ActionResult <AssetTypeDTO> > Post(AssetTypeDTO assetType)
 {
     return(Created($"/assettypes/{assetType.Id}", assetType));
 }