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); }
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); } }
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); }