public async Task <IActionResult> deleteBanners([FromBody] DeleteBannerDto DeleteBannerDto) { string Bannerdeletestatus = string.Empty; try { Bannerdeletestatus = await _BannerService.DeleteBanners(DeleteBannerDto); if (Bannerdeletestatus == "Banner deleted successfully") { return(Ok(new GenericResultDto <string> { Result = Bannerdeletestatus })); } return(BadRequest(new GenericResultDto <string> { Result = Bannerdeletestatus })); } catch (Exception err) { return(BadRequest(new GenericResultDto <string> { Result = err.Message })); } }
public async Task <string> DeleteBanners(DeleteBannerDto DeleteBannerDto) { DateTime Presentdate = Convert.ToDateTime(GetPresentdate); DateTime Timezone = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(Presentdate, TimeZoneInfo.Local.Id, DeleteBannerDto.CountryTimezone); var GetBannerdetails = Repository.SingleOrDefault(x => x.Id == DeleteBannerDto.BannerId); if (GetBannerdetails.StartDate > Timezone) { GetBannerdetails.Status = 0; await Repository.UpdateAsync(GetBannerdetails); return("Banner deleted successfully"); } else { return("Sorry you are not allowed to update,Banner is live now"); } }