public ServiceResponse <TenderTask> UpdateTask(Guid id, TenderTask entity)
        {
            var response = new ServiceResponse <TenderTask>();

            try
            {
                var originalEntity = this._entityRepository.GetById(id);
                if (originalEntity != null)
                {
                    originalEntity.Copy(entity, false);
                    this._entityRepository.Update(originalEntity);
                }
                else
                {
                    this._entityRepository.Create(entity);
                }

                // Set Successfull Response
                response.StatusCode   = 200;
                response.ErrorMessage = null;
                response.Content      = entity;
                return(response);
            }
            catch (Exception ex)
            {
                // Set Error Response
                response.StatusCode   = 500;
                response.ErrorMessage = ex.Message;
                response.Content      = entity;
                return(response);
            }
        }
        public ServiceResponse <TenderTask> CreateTask(TenderTask entity)
        {
            var response = new ServiceResponse <TenderTask>();

            try
            {
                this._entityRepository.Create(entity);

                // Set Successfull Response
                response.StatusCode   = 200;
                response.ErrorMessage = null;
                response.Content      = entity;
                return(response);
            }
            catch (Exception ex)
            {
                // Set Error Response
                response.StatusCode   = 500;
                response.ErrorMessage = ex.Message;
                response.Content      = entity;
                return(response);
            }
        }
        public IActionResult Post([FromBody] TenderTask entity)
        {
            var response = this._entityService.CreateTask(entity);

            return(StatusCode(response.StatusCode, response));
        }
Exemple #4
0
        public IActionResult UpdateTask(Guid id, [FromBody] TenderTask entity)
        {
            var response = this._entityService.UpdateTask(id, entity);

            return(StatusCode(response.StatusCode, response));
        }