示例#1
0
        public async Task <ActionResultResponse> Delete(string tenantId, string eventId)
        {
            var info = await _eventRepository.GetInfo(eventId);

            if (info == null)
            {
                return(new ActionResultResponse(-1, _websiteEventResourceService.GetString("Event does not exists. Please try again.")));
            }

            if (info.TenantId != tenantId)
            {
                return(new ActionResultResponse(-2, _sharedResourceService.GetString(ErrorMessage.NotHavePermission)));
            }

            if (info.Status != ApproverStatus.Draft && info.Status != ApproverStatus.Decline)
            {
                return(new ActionResultResponse(-1, _websiteEventResourceService.GetString("Event is used. Please try again.")));
            }

            var infoReg = await _registerRepository.GetInfoByEventId(eventId);

            if (infoReg.Count > 0)
            {
                return(new ActionResultResponse(-1, _websiteEventResourceService.GetString("event is already exists. Please try again.")));
            }

            var result = await _eventRepository.Delete(eventId);

            return(new ActionResultResponse(result, _websiteEventResourceService.GetString("Delete event successful.")));
        }