Example #1
0
        public async Task <ApiResponse> Post(AddTagVMRequest entity)
        {
            try
            {
                long max   = 0;
                var  query = await _entityRepository.TableNoTracking.FirstOrDefaultAsync();

                if (query != null)
                {
                    max = await _entityRepository.TableNoTracking.MaxAsync(x => x.Id);
                }
                Tag tag = new()
                {
                    Name_ar = entity.Name_ar,
                    Name_en = entity.Name_en,
                    Name_fr = entity.Name_fr,
                    Name_tr = entity.Name_tr,
                    Name_ru = entity.Name_ru,
                    Code    = $"Tag_{max + 1}"
                };
                var newEntity = await _entityRepository.InsertAsync(tag);

                return(ApiResponse.Create(HttpStatusCode.OK, newEntity.Id));
            }
            catch (Exception)
            {
                return(ApiResponse.Create(HttpStatusCode.InternalServerError, null, "InternalServerError_Error"));
            }
        }
Example #2
0
        public async Task <long> Create(AddTagVMRequest entity)
        {
            var response = await _httpService.Post2 <AddTagVMRequest, long>(url, entity);

            if (!response.Success)
            {
                throw new ApplicationException(await response.GetBody());
            }
            return(response.Response);
        }
        public async Task <ActionResult> Post(AddTagVMRequest entity)
        {
            #region Start the watch
            var watch = new Stopwatch();
            watch.Start();
            #endregion

            var result = await _entityServices.Post(entity);

            #region End the watch
            watch.Stop();
            result.Meta.TotalProcessingTime = watch.ElapsedMilliseconds;
            #endregion

            return(Ok(result));
        }