Пример #1
0
 public static void MapTo(this JobAdList list, JobAdListEntity entity)
 {
     entity.name        = list.Name;
     entity.ownerId     = list.OwnerId;
     entity.isDeleted   = list.IsDeleted;
     entity.createdTime = list.CreatedTime;
     entity.listType    = list.ListType;
 }
Пример #2
0
 void IJobAdListsRepository.CreateList(JobAdList list)
 {
     using (var dc = CreateContext())
     {
         dc.JobAdListEntities.InsertOnSubmit(list.Map());
         dc.SubmitChanges();
     }
 }
Пример #3
0
        public static JobAdListEntity Map(this JobAdList list)
        {
            var entity = new JobAdListEntity {
                id = list.Id
            };

            list.MapTo(entity);
            return(entity);
        }
Пример #4
0
 void IJobAdListsRepository.UpdateList(JobAdList list)
 {
     using (var dc = CreateContext())
     {
         var entity = GetListEntity(dc, list.Id);
         if (entity != null)
         {
             list.MapTo(entity);
             dc.SubmitChanges();
         }
     }
 }
Пример #5
0
 private static bool CanAccessFolder(IMember member, JobAdList folder)
 {
     if (member == null)
     {
         return(false);
     }
     if (folder == null)
     {
         return(false);
     }
     if (folder.IsDeleted)
     {
         return(false);
     }
     return(true);
 }
Пример #6
0
        private static bool CanAccessBlockList(IMember member, JobAdList blockList, bool allowDeleted)
        {
            if (member == null)
            {
                return(false);
            }
            if (blockList == null)
            {
                return(false);
            }
            if (!allowDeleted && blockList.IsDeleted)
            {
                return(false);
            }

            return(true);
        }
Пример #7
0
        private void Validate(IHasId <Guid> member, JobAdList folder, string newName)
        {
            if (string.IsNullOrEmpty(newName))
            {
                throw new ValidationErrorsException(new RequiredValidationError("name"));
            }

            // Don't need to check the name of a deleted folder.

            if (folder.IsDeleted)
            {
                return;
            }

            // Check no folder with the same name exists.

            if (_jobAdListsQuery.GetList <JobAdFolder>(member.Id, newName, ListTypes) != null)
            {
                throw new ValidationErrorsException(new DuplicateValidationError("Name"));
            }
        }
Пример #8
0
 void IJobAdListsCommand.UpdateList(JobAdList jobAdList)
 {
     jobAdList.Validate();
     _repository.UpdateList(jobAdList);
 }
Пример #9
0
 void IJobAdListsCommand.CreateList(JobAdList jobAdList)
 {
     jobAdList.Prepare();
     jobAdList.Validate();
     _repository.CreateList(jobAdList);
 }