Пример #1
0
        public void Handle(UpdateAdCommand command)
        {
            var user = UserRepository.Get(command.UserId);

            Guard.IsNotNull(user, "user");
            if (!user.UserRole.HasFlag(UserRole.Admin))
            {
                throw new PowerException("权限不足");
            }
            var ad = AdRepository.Get(command.Id);

            Guard.IsNotNull(ad, "ad");
            ad.AdDesc        = command.AdDesc;
            ad.AdImg         = command.AdImg;
            ad.AdName        = command.AdName;
            ad.IsShow        = command.IsShow;
            ad.Sort          = command.Sort;
            ad.SmallAdImg    = command.SmallImg;
            ad.StandardAdImg = command.StandardAdImg;

            if (command.Sort == null || command.Sort <= 0)
            {
                ad.Sort = GetAdMaxSort();
            }

            AdRepository.Update(ad);
        }
Пример #2
0
        public Task SendDeniedMessage(AdApplication adApplication, Account userAccount)
        {
            Ad     ad = adRepository.Get(adApplication.AdId);
            string jobApplicationUnSuccessfulMessage = string.Format(@"Your Job Application to job {0} was unsuccesful, Please log on to http://www.jobmtaani.co.ke/#/profile to apply for more roles",
                                                                     ad.AdTitle);

            return(SendEmailMessage(userAccount.Email, jobApplicationUnSuccessfulMessage, "Job Mtaani Job Activity"));
        }
Пример #3
0
        public HttpResponseMessage GetAd(HttpRequestMessage request, [FromBody] int adId)
        {
            return(GetHttpResponse(request, () =>
            {
                HttpResponseMessage response = null;

                Ad account = adRepository.Get(adId);

                response = request.CreateResponse <Ad>(HttpStatusCode.OK, account);

                return response;
            }));
        }
Пример #4
0
        //[PrincipalPermission(SecurityAction.Demand, Role = SecurityValueObject.JonMtaaniAdminRole)]
        //[PrincipalPermission(SecurityAction.Demand, Name = SecurityValueObject.JonMtaaniUser)]
        public Ad GetAd(int adId)
        {
            return(ExecuteFaultHandledOperation(() =>
            {
                IAdRepository adRepository = dataRepositoryFactory.GetDataRepository <IAdRepository>();
                Ad ad = adRepository.Get(adId);
                if (ad == null)
                {
                    NotFoundException ex = new NotFoundException(string.Format("Ad with ID of {0} is not in database", adId));
                    throw new FaultException <NotFoundException>(ex, ex.Message);
                }

                return ad;
            }));
        }
Пример #5
0
        public void Handle(DeleteAdCommand command)
        {
            var user = UserRepository.Get(command.UserId);

            Guard.IsNotNull(user, "user");
            if (!user.UserRole.HasFlag(UserRole.Admin))
            {
                throw new PowerException("权限不足");
            }

            var ad = AdRepository.Get(command.Id);

            Guard.IsNotNull(ad, "ad");
            AdRepository.Delete(ad);
        }