Beispiel #1
0
 public int Add(ActivityDto model)
 {
     var isExistName = _activityRepository.Exist(t => t.ActivityName == model.ActivityName);
     if (isExistName)
         return 2001;
     var isExistId = _activityRepository.Exist(t => t.ActivityID == model.ActivityID);
     if (isExistId)
         return 2002;
     model.CreateTime = DateTime.Now;
     model.LastOperationTime = DateTime.Now;
     model.UserID = (AuthorHelper.GetAuthorInfo(true) as ManageUsers).ID;
     var entity = AutoMapper.Mapper.Map<Activity>(model);
     var result = _activityRepository.Insert(entity);
     return result > 0 ? 0 : -1;
 }
Beispiel #2
0
 public bool Update(ActivityDto model)
 {
     var oldModel = _activityRepository.GetModel(t => t.ID == model.ID);
     if (oldModel == null)
         return false;
     model.CreateTime = oldModel.CreateTime;
     model.IsDel = oldModel.IsDel;
     model.LastOperationTime = DateTime.Now;
     model.Type = oldModel.Type;
     var entity = AutoMapper.Mapper.Map<Activity>(model);
     return _activityRepository.Update(entity);
 }