public async Task <ActionResult <UserSignInLog> > PostAnItem([FromBody] UserSignInLog item)
        {
            try
            {
                _context.UserSignInLogs.Add(item);
                _context.Entry(item.UserInfo).State = EntityState.Unchanged;
                await _context.SaveChangesAsync();

                return(CreatedAtAction(nameof(GetById), new { id = item.Id }, item));
            }
            catch (Exception ex)
            {
                Log.ForContext <UserSignInLogsController>().Error(ex.Message);
                return(BadRequest(ex.Message));
            }
        }
Exemplo n.º 2
0
        public async Task <ActionResult <Service> > Get(int id)
        {
            try
            {
                var item = await _context.Services.FindAsync(id);

                if (item == null)
                {
                    return(NotFound());
                }
                await _context.Entry(item).Collection(x => x.ServiceDetails).LoadAsync();

                return(item);
            }
            catch (Exception ex)
            {
                Log.ForContext <ServicesController>().Error(ex.Message);
                return(BadRequest(ex.Message));
            }
        }
        public async Task <ActionResult <IEnumerable <UserSubscription> > > Get()
        {
            try
            {
                var datas = await _context.UserSubscriptions.ToListAsync();

                datas.ForEach(x => _context.Entry(x).Reference(r => r.UserDetail).Load());
                datas.ForEach(x => _context.Entry(x).Reference(r => r.Service).Load());
                return(datas);
            }
            catch (Exception ex)
            {
                Log.ForContext <UserSubscriptionsController>().Error(ex.Message);
                return(BadRequest(ex.Message));
            }
        }
        public async Task <IActionResult> PutAnItem(int id, [FromBody] Department item)
        {
            try
            {
                if (id != item.Id)
                {
                    return(BadRequest());
                }

                _context.Entry(item).State = EntityState.Modified;
                await _context.SaveChangesAsync();

                return(AcceptedAtAction(nameof(GetById), new { id = item.Id }, item));
            }
            catch (Exception ex)
            {
                Log.ForContext <DepartmentsController>().Error(ex.Message);
                return(BadRequest(ex.Message));
            }
        }
Exemplo n.º 5
0
        public async Task <ActionResult <Tender> > GetById(int id)
        {
            try
            {
                var tenderitem = await _context.Tenders.FindAsync(id);


                if (tenderitem == null)
                {
                    return(NotFound());
                }

                await _context.Entry(tenderitem).Collection(x => x.TenderDocs).LoadAsync();

                return(tenderitem);
            }
            catch (Exception ex)
            {
                Log.ForContext <TendersController>().Error(ex.Message);
                return(BadRequest(ex.Message));
            }
        }
Exemplo n.º 6
0
        public async Task <ActionResult <UserDetail> > GetById(int id)
        {
            try
            {
                var item = await _context.UserDetails.FindAsync(id);

                if (item == null)
                {
                    return(NotFound());
                }
                await _context.Entry(item).Reference(x => x.UserInfo).LoadAsync();

                return(item);
            }
            catch (Exception ex)
            {
                Log.ForContext <UserDetailsController>().Error(ex.Message);
                return(BadRequest(ex.Message));
            }
        }