public Result Schedule(FormDataCollection form) { var contactId = form.Get("contactId").ToInt32(); var entityDbs = AppointmentInterviewRepository.GetAllByContactId(contactId); string noteConsulant = ""; var userConsulant = UserContext.GetCurrentUser(); noteConsulant = userConsulant.IsDATester == false?form.Get("notes") : "VIP+: " + form.Get("notes"); var entity = new AppointmentInterviewInfo { ContactId = contactId, Notes = noteConsulant, NotesCM = form.Get("notesCM"), UserId = userConsulant.UserID, TimeSlotId = form.Get("timeSlotId").ToInt32(), TeacherTypeId = form.Get("teacherTypeId").ToInt32(), LevelTesterId = form.Get("levelTesterId").ToInt32(), StatusInterviewId = form.Get("statusInterviewId").ToInt32(), CasecAccountId = entityDbs.IsNullOrEmpty() ? 0 : entityDbs[0].CasecAccountId, AppointmentDate = form.Get("appointmentDate").ToDateTime("ddMMyyyy") ?? DateTime.Now, }; var reSchedule = form.Get("reSchedule").ToBoolean(); entity.StatusInterviewId = reSchedule ? (int)StatusInterviewType.HocVienDoiLichPhongVan : (int)StatusInterviewType.DaDatHang; var result = reSchedule ? (new HelpUtils()).SendChangeInterviewInfo(entity) : (new HelpUtils()).SendInterviewInfo(entity, userConsulant.IsDATester); if (result.Code == 0) { result.Tag = entity.StatusInterviewId; AppointmentInterviewRepository.Create(entity); ContactLevelInfoRepository.UpdateHasAppointmentInterview(entity.ContactId, true); } return(result); }
public Result CancelSchedule(FormDataCollection form) { var contactId = form.Get("contactId").ToInt32(); var entityDbs = AppointmentInterviewRepository.GetAllByContactId(contactId) ?? new List <AppointmentInterviewInfo>(); var entity = entityDbs.OrderBy(c => c.Id).LastOrDefault(); if (entity != null) { var result = (new HelpUtils()).SendCancelInterview(entity.ContactId); if (result.Code == 0) { entity.StatusInterviewId = (int)StatusInterviewType.HocVienHuyPhongVan; AppointmentInterviewRepository.Update(entity); ContactLevelInfoRepository.UpdateHasAppointmentInterview(entity.ContactId, false); } return(result); } return(new Result { Code = 1, Description = "Lịch không tồn tại, bạn phải đặt lịch trước khi hủy lịch" }); }
public List <AppointmentInterviewInfo> GetAllByContactId(int contactId) { var list = AppointmentInterviewRepository.GetAllByContactId(contactId); if (!list.IsNullOrEmpty()) { foreach (var item in list) { item.AppointmentDateString = item.AppointmentDate.HasValue ? item.AppointmentDate.Value.ToString("dd/MM/yyyy") : string.Empty; var timeSlot = CatalogRepository.GetInfo <TimeSlotInfo>(item.TimeSlotId); item.TimeSlotName = timeSlot != null ? timeSlot.Name : string.Empty; var teacherType = CatalogRepository.GetInfo <TeacherTypeInfo>(item.TeacherTypeId); item.TeacherTypeName = teacherType != null ? teacherType.Name : string.Empty; item.NotesCM = item.NotesCM.IsStringNullOrEmpty() ? string.Empty : item.NotesCM; item.StatusInterviewName = ObjectExtensions.GetEnumDescription((StatusInterviewType)item.StatusInterviewId); } return(list); } return(null); }
// GET api/<controller>/5 public AppointmentInterviewInfo Get(int id) { return(AppointmentInterviewRepository.GetInfo(id)); }
// GET api/<controller> public IEnumerable <AppointmentInterviewInfo> Get() { return(AppointmentInterviewRepository.GetAll()); }