public ActivityResponse UpdateActivity(ActivityEntity Activity) { var response = new ActivityResponse { Acknowledge = AcknowledgeType.Success }; try { if (!Activity.Validate()) { foreach (string error in Activity.ValidationErrors) { response.Message += error + Environment.NewLine; } response.Acknowledge = AcknowledgeType.Failure; return(response); } response.Message = ActivityDao.UpdateActivity(Activity); if (!string.IsNullOrEmpty(response.Message)) { response.Acknowledge = AcknowledgeType.Failure; return(response); } response.ActivityId = Activity.ActivityId; return(response); } catch (Exception ex) { response.Acknowledge = AcknowledgeType.Failure; response.Message = ex.Message; return(response); } }
public ActivityResponse InsertActivityConvert(ActivityEntity Activity) { var response = new ActivityResponse { Acknowledge = AcknowledgeType.Success }; try { var activity = ActivityDao.GetActivityByCode(Activity.ActivityCode.Trim()); if (activity.Count != 0) { response.Acknowledge = AcknowledgeType.Failure; response.Message = @"Mã công việc " + Activity.ActivityCode.Trim() + @" đã tồn tại!"; return(response); } if (!Activity.Validate()) { foreach (string error in Activity.ValidationErrors) { response.Message += error + Environment.NewLine; } response.Acknowledge = AcknowledgeType.Failure; return(response); } response.Message = ActivityDao.InsertActivity(Activity); if (!string.IsNullOrEmpty(response.Message)) { response.Acknowledge = AcknowledgeType.Failure; return(response); } response.ActivityId = Activity.ActivityId; return(response); } catch (Exception ex) { response.Acknowledge = AcknowledgeType.Failure; response.Message = ex.Message; return(response); } }