Ejemplo n.º 1
0
        public async Task <IActionResult> CreateCase([FromBody] KeyValuePairResource KeyValuePairResource)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var caseObject = mapper.Map <KeyValuePairResource, Case>(KeyValuePairResource);

            context.Cases.Add(caseObject);
            await context.SaveChangesAsync();

            var result = mapper.Map <Case, KeyValuePairResource>(caseObject);

            return(Ok(result));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> CreateStorage([FromBody] KeyValuePairResource KeyValuePairResource)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var storage = mapper.Map <KeyValuePairResource, Storage>(KeyValuePairResource);

            context.Storages.Add(storage);
            await context.SaveChangesAsync();

            var result = mapper.Map <Storage, KeyValuePairResource>(storage);

            return(Ok(result));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> CreateCoolingFan([FromBody] KeyValuePairResource KeyValuePairResource)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var coolingFan = mapper.Map <KeyValuePairResource, Coolingfan>(KeyValuePairResource);

            context.CoolingFans.Add(coolingFan);
            await context.SaveChangesAsync();

            var result = mapper.Map <Coolingfan, KeyValuePairResource>(coolingFan);

            return(Ok(result));
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> CreateGpu([FromBody] KeyValuePairResource KeyValuePairResource)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var gpu = mapper.Map <KeyValuePairResource, GPU>(KeyValuePairResource);

            context.GPUs.Add(gpu);
            await context.SaveChangesAsync();

            var result = mapper.Map <GPU, KeyValuePairResource>(gpu);

            return(Ok(result));
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> CreateSaleItem([FromBody] SaleItemResource saleItemResource)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var saleItem = mapper.Map <SaleItemResource, SaleItem>(saleItemResource);

            context.SaleItems.Add(saleItem);
            await context.SaveChangesAsync();

            var result = mapper.Map <SaleItem, SaleItemResource>(saleItem);

            return(Ok(result));
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> CreateMotherboard([FromBody] KeyValuePairResource KeyValuePairResource)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var motherboard = mapper.Map <KeyValuePairResource, Motherboard>(KeyValuePairResource);

            context.Motherboards.Add(motherboard);
            await context.SaveChangesAsync();

            var result = mapper.Map <Motherboard, KeyValuePairResource>(motherboard);

            return(Ok(result));
        }
Ejemplo n.º 7
0
        public async Task <IActionResult> CreateRam([FromBody] KeyValuePairResource KeyValuePairResource)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var ram = mapper.Map <KeyValuePairResource, RAM> (KeyValuePairResource);

            context.RAMs.Add(ram);
            await context.SaveChangesAsync();

            var result = mapper.Map <RAM, KeyValuePairResource>(ram);

            return(Ok(result));
        }
Ejemplo n.º 8
0
        public async Task <IActionResult> CreatePowersupply([FromBody] KeyValuePairResource KeyValuePairResource)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var powerSupply = mapper.Map <KeyValuePairResource, Powersupply>(KeyValuePairResource);

            context.PowerSupplys.Add(powerSupply);
            await context.SaveChangesAsync();

            var result = mapper.Map <Powersupply, KeyValuePairResource>(powerSupply);

            return(Ok(result));
        }
Ejemplo n.º 9
0
        public async Task <IActionResult> CreateAccount([FromBody] AccountResource accountResource)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var account = mapper.Map <AccountResource, Account>(accountResource);

            context.Accounts.Add(account);
            await context.SaveChangesAsync();

            var result = mapper.Map <Account, AccountResource>(account);

            return(Ok(result));
        }
Ejemplo n.º 10
0
        public async Task <IActionResult> CreateOrder([FromBody] OrderResource orderResource)
        {
            // if (!ModelState.IsValid)
            // {
            //     return BadRequest(ModelState);
            // }
            var order = mapper.Map <OrderResource, Order>(orderResource);

            var dateAndTime = DateTime.Now;

            order.OrderDate = dateAndTime.Date;

            context.Orders.Add(order);
            await context.SaveChangesAsync();

            var result = mapper.Map <Order, OrderResource>(order);

            return(Ok(result));
        }