private void btnSave_Click(object sender, EventArgs e) { try { if (!CheckData()) { return; } //Table Shift Shift shift = new Shift(); shift.Id = _id; shift.ShiftNo = txtShiftNo.Text.Trim(); shift.Note = txtNote.Text.Trim(); shift.Status = (chkUsing.Checked ? GlobalConstants.StatusValue.Using : GlobalConstants.StatusValue.NoUse); _shiftRepository.Save(shift); UnitOfWork unitOfWork = new UnitOfWork(_projectDataContext); int result = unitOfWork.Complete(); if (result > 0) { if (String.IsNullOrEmpty(_id)) { if (_quickAdd) { this.Tag = txtShiftNo.Text.Trim(); DialogResult = DialogResult.OK; Close(); } else { XtraMessageBox.Show(LanguageTranslate.ChangeLanguageText("Lưu thành công"), LanguageTranslate.ChangeLanguageText("Thông báo")); Clear(); } } else { DialogResult = DialogResult.OK; Close(); } } else { XtraMessageBox.Show(LanguageTranslate.ChangeLanguageText("Lưu thất bại"), LanguageTranslate.ChangeLanguageText("Thông báo"), MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } catch (Exception ex) { XtraMessageBox.Show(LanguageTranslate.ChangeLanguageText("Lưu thất bại"), LanguageTranslate.ChangeLanguageText("Thông báo"), MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } }
public ActionResult AcceptOpenShift(string From, string Body) { var response = new TwilioResponse(); var employee = _employeeRepository.Select().Where(e => e.PhoneNumber == From).FirstOrDefault(); if (employee == null) { return(TwiML(response)); } //parse and process sms message body var parameters = Body.Split(' '); if (parameters.Count() < 2) { response.Message("Whoops. Not sure what that command was. Try again."); } if (parameters[0].ToLower() == "yes") { var openShift = _shiftRepository.Select().Where(s => s.ID.ToString() == parameters[1]).FirstOrDefault(); if (openShift.AssignedEmployee == null) { openShift.AssignedEmployee = employee; _shiftRepository.Update(openShift); _shiftRepository.Save(); var message = string.Format( "Awesome. Thanks for stepping up. See you on {0} at {1}", openShift.StartTime.ToLongDateString(), openShift.StartTime.ToShortTimeString() ); response.Message(message); } else { response.Message("Ohhh, so close. Try again next time"); } } return(TwiML(response)); }