Beispiel #1
0
        public IActionResult Delete(int?countryId)
        {
            try
            {
                if (!countryId.HasValue)
                {
                    return(StatusCode(400, StatusCodes.ReturnStatusObject("No parameter provided.")));
                }
                var result = _countryRepository.Delete(countryId);

                if (result)
                {
                    _logger.LogInformation($"ID : {countryId} has been successfully deleted.");
                    return(StatusCode(200, StatusCodes.ReturnStatusObject($"ID : {countryId} has been successfully deleted.")));
                }
                else
                {
                    _logger.LogError("Country ID : {0} was not deleted.", countryId);
                    return(StatusCode(400, StatusCodes.ReturnStatusObject($"Delete was unsuccessful.")));
                }
            }
            catch (Exception e)
            {
                _logger.LogError("The Country delete has failed. Error - {0}", e.Message);
                return(StatusCode(400, StatusCodes.ReturnStatusObject("The delete has failed.")));
            }
        }
Beispiel #2
0
        public async Task <IActionResult> Delete([FromBody] CountryEntry pModel)
        {
            // Validation
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            if (ValidatemCountry(pModel, pModel.AuditColumns, true) == false)
            {
                return(BadRequest(ModelState));
            }
            else
            {
                // Execution of concrete process
                SQLResult result = new SQLResult();
                result = await _repo.Delete(pModel);

                if (result.ErrorNo > 0)
                {
                    return(BadRequest(result));
                }
                else
                {
                    return(Ok(result));
                }
            }
        }
Beispiel #3
0
        public IHttpActionResult Delete(int id)
        {
            ApiResData res = new ApiResData();

            try
            {
                if (!ModelState.IsValid)
                {
                    rs.SetErrorStatus(eFunc.fg.SFailed);
                    resObj = JObject.FromObject(res.ResCUD(new object[] { rs }, eFunc.fg.Delete, new Exception(eFunc.fg.DataNf)));
                    return(Content(HttpStatusCode.NotFound, resObj));
                }

                rs = repo.Delete(id, "System", CurrentUser.GetCurrentDateTime());
                if (rs.IsSuccess)
                {
                    rs.SetSuccessStatus();
                }
                else
                {
                    rs.SetErrorStatus(eFunc.fg.SFailed);
                }

                resObj = JObject.FromObject(res.ResCUD(new object[] { rs }, eFunc.fg.Delete, null));
                return(Content(HttpStatusCode.OK, resObj));
            }
            catch (Exception ex)
            {
                rs.SetErrorStatus(ex.Message);
                resObj = JObject.FromObject(res.ResCUD(new object[] { rs }, eFunc.fg.Delete, new Exception(eFunc.fg.DFailed)));
                return(Content(HttpStatusCode.BadRequest, resObj));
            }
        }
        public virtual async Task <ActionResult> Delete(int ID)
        {
            _country.Delete(ID);
            await _uow.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Beispiel #5
0
        public async Task <ActionResult <Country> > DeleteCountry(string id)
        {
            var country = await repository.GetSingle(id);

            if (country == null)
            {
                return(StatusCode(StatusCodes.Status404NotFound, country));
            }

            country.Code        = country.Code;
            country.Description = country.Description;

            var result = await repository.Delete(country);

            return(StatusCode(StatusCodes.Status200OK, result));
        }
Beispiel #6
0
        public bool Delete(string countryid)
        {
            var result = icountryrepobj.Delete(countryid);

            return(result);
        }
Beispiel #7
0
 public int Delete(int id)
 {
     return(_country.Delete(id));
 }