예제 #1
0
        public static InterestedClass ToEntity(ViewInterestedClass model)
        {
            InterestedClass item = new InterestedClass();

            item.Id         = model.Id;
            item.ClassId    = model.ClassId;
            item.UserId     = model.UserId;
            item.IsDeleted  = model.IsDeleted;
            item.CreateTime = model.CreateTime;

            return(item);
        }
예제 #2
0
 public int Add(ViewInterestedClass interested)
 {
     if (Exists(interested.ClassId, interested.UserId))
     {
         return(Delete(interested.ClassId, interested.UserId));
     }
     else
     {
         interested.CreateTime = DateTime.Now;
         InterestedClass ic = _repository.Add(ViewInterestedClass.ToEntity(interested));
         return(ic.Id);
     }
 }
예제 #3
0
        public static ViewInterestedClass ToViewModel(InterestedClass model)
        {
            if (model == null)
            {
                return(null);
            }

            ViewInterestedClass item = new ViewInterestedClass();

            item.Id                    = model.Id;
            item.ClassId               = model.ClassId;
            item.UserId                = model.UserId;
            item.IsDeleted             = model.IsDeleted;
            item.CreateTime            = model.CreateTime;
            item.Class                 = model.Class;
            item.Class.InterestedClass = null;
            return(item);
        }