Example #1
0
        public async Task <RequestDbo> AddOrUpdate(RequestDbo request)
        {
            try
            {
                Log.Debug($"{nameof(AddOrUpdate)} called on {nameof(RequestRepository)}");

                _context.Requests.Update(request);
                request.Id = await _context.SaveChangesAsync();

                Log.Debug($"Request saved in method {nameof(AddOrUpdate)} called on {nameof(RequestRepository)}");
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
                Log.Error($"Error in method {nameof(AddOrUpdate)} in {nameof(RequestRepository)}");
            }

            return(request);
        }
Example #2
0
        public async Task <RequestDbo> Get(int id)
        {
            RequestDbo item = null;

            try
            {
                Log.Debug($"{nameof(Get)} called on {nameof(RequestRepository)} with param id of \"{id}\"");

                item = await _context.Requests.FirstOrDefaultAsync(x => x.Id == id);

                Log.Debug($"{(item == null ? "0" : "1")} item(s) was found in {nameof(RequestRepository)} for id \"{id}\"");
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
                Log.Error($"Error in method {nameof(Get)} in {nameof(RequestRepository)}", ex);
            }

            return(item);
        }