public static void AddUpdatePhoneBookDetails(PhoneDetails phoneDetails) { try { var context = new PhoneContext(); if (phoneDetails.PhoneBookId == 0) { context.dbPhoneDetails.Add(phoneDetails); context.SaveChanges(); } else { var result = context.dbPhoneDetails.Find(phoneDetails.PhoneBookId); if (result != null) { context.Entry(result).CurrentValues.SetValues(phoneDetails); context.SaveChanges(); } } } catch (Exception ex) { throw ex; } }
private void ValidateBeforeSave() { if (txtFirstName.Text == string.Empty || txtLastName.Text == string.Empty || txtPhoneNo.Text == string.Empty) { Clear(); ShowFailureMessage(); } else { PhoneDetails phoneDetails = new PhoneDetails { PhoneBookId = 0, Address = txtAddress.Text.Trim(), Email = txtEmail.Text.Trim(), FirstName = txtFirstName.Text.Trim(), LastName = txtLastName.Text.Trim(), MiddleName = txtMiddleName.Text.Trim(), PhoneNo = txtPhoneNo.Text.Trim() }; PhoneBookBL.AddPhoneBookDetails(phoneDetails); Clear(); ShowSuccessMessage(); ShowData(); } }
public static void AddPhoneBookDetails(PhoneDetails phoneDetails) { try { PhoneBookDL.AddUpdatePhoneBookDetails(phoneDetails); } catch (Exception ex) { throw ex; } }
private async Task <DialogTurnResult> NameStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken) { phoneDetails = (PhoneDetails)stepContext.Options; if (phoneDetails.Name == null) { return(await stepContext.PromptAsync(nameof(TextPrompt), new PromptOptions { Prompt = MessageFactory.Text("어느 전화부서를 찾으시나요?"), }, cancellationToken)); } else { return(await stepContext.NextAsync(phoneDetails.Name, cancellationToken)); } }
public static void DeletePhoneBookDetailsById(int phoneBookId) { try { var context = new PhoneContext(); PhoneDetails detail = new PhoneDetails { PhoneBookId = phoneBookId }; context.Entry(detail).State = EntityState.Deleted; context.SaveChanges(); } catch (Exception ex) { throw ex; } }
public static PhoneDetails GetPhoneBookDetailsById(int phoneBookId) { try { PhoneDetails phoneDetails = new PhoneDetails(); var context = new PhoneContext(); if (context.dbPhoneDetails.Any()) { phoneDetails = context.dbPhoneDetails.Where(a => a.PhoneBookId == phoneBookId).FirstOrDefault(); } return(phoneDetails); } catch (Exception ex) { throw ex; } }
public ActionResult AddorEdit(PhoneDetails phno) { if (ModelState.IsValid) { if (phno.ContactID == 0) { HttpResponseMessage response = GlobalVariables.WebApiClient.PostAsJsonAsync("PhoneBook", phno).Result; TempData["SuccessMessage"] = "Saved Successfully"; } else { HttpResponseMessage response = GlobalVariables.WebApiClient.PutAsJsonAsync("PhoneBook/" + phno.ContactID, phno).Result; TempData["SuccessMessage"] = "Updated Successfully"; } return(RedirectToAction("Index")); } return(View("AddorEdit")); }
protected void phoneBookGrid_RowUpdating(object sender, System.Web.UI.WebControls.GridViewUpdateEventArgs e) { PhoneDetails phoneDetail = new PhoneDetails(); phoneDetail.PhoneBookId = Convert.ToInt32((phoneBookGrid.Rows[e.RowIndex].FindControl("lblID") as Label).Text); phoneDetail.FirstName = (phoneBookGrid.Rows[e.RowIndex].FindControl("txtFirstName") as TextBox).Text; phoneDetail.MiddleName = (phoneBookGrid.Rows[e.RowIndex].FindControl("txtMiddleName") as TextBox).Text; phoneDetail.LastName = (phoneBookGrid.Rows[e.RowIndex].FindControl("txtLastName") as TextBox).Text; phoneDetail.Email = (phoneBookGrid.Rows[e.RowIndex].FindControl("txtEmail") as TextBox).Text; phoneDetail.PhoneNo = (phoneBookGrid.Rows[e.RowIndex].FindControl("txtPhoneNo") as TextBox).Text; phoneDetail.Address = (phoneBookGrid.Rows[e.RowIndex].FindControl("txtAddress") as TextBox).Text; PhoneBookBL.UpdatePhoneBookDetails(phoneDetail); phoneBookGrid.EditIndex = -1; Clear(); ShowSuccessMessage(); ShowData(); }
static void Main(string[] args) { //init database PhoneDetails db = new PhoneDetails(); using (db) { //create phones Phone p1 = new Phone("Samsung S20", 500, "Android", "/images/android.png", "/images/s20.jpg"); Phone p2 = new Phone("iPhone 11", 600, "IOS", "/images/apple.png", "/images/iphone11.png"); //db.Phone.Add(p1); //db.Phone.Add(p2); //Console.WriteLine("Players added to database"); db.SaveChanges(); Console.WriteLine("Database saved"); } }
/// <summary> /// Updates the specified phone dto. /// </summary> /// <param name="phoneDto">The phone dto.</param> /// <param name="details">The details.</param> public static void Update(this PhoneDto phoneDto, PhoneDetails details) { var clli1 = details.ProvisionDetails.CLLI1; var port1 = details.ProvisionDetails.Port1; var clli2 = details.ProvisionDetails.CLLI2; var port2 = details.ProvisionDetails.Port2; phoneDto.PhoneProvSpec.DSLUnitAddress = new List<DSLUnitAddressDto> { new DSLUnitAddressDto { // TODO: case coercion done here for bug/hotfix 12372 — should be handled in Rosettian. CLLICode = !String.IsNullOrWhiteSpace(clli1) ? clli1.ToUpper() : string.Empty, HSIPort = !String.IsNullOrWhiteSpace(port1) ? port1 : string.Empty }, new DSLUnitAddressDto { // TODO: case coercion done here for bug/hotfix 12372 — should be handled in Rosettian. CLLICode = !String.IsNullOrWhiteSpace(clli2) ? clli2.ToUpper() : string.Empty, HSIPort = !String.IsNullOrWhiteSpace(port2) ? port2 : string.Empty } }; phoneDto.PhoneNumber = details.TN ?? string.Empty; phoneDto.PhoneProvSpec.LongDistancePIC.Code = details.ProvisionDetails.PIC ?? string.Empty; phoneDto.PhoneProvSpec.LocalPIC.Code = details.ProvisionDetails.LPIC ?? string.Empty; phoneDto.PhoneProvSpec.CIDLocalName = details.ProvisionDetails.CIDName; phoneDto.PhoneProvSpec.EquipmentId = details.RGPort; phoneDto.PhoneNumberStatus = details.ProvisionDetails.TNStatus; phoneDto.PhoneProvSpec.ServiceEnabled = details.ProvisionDetails.PhoneServiceEnabled; // TODO: case coercion done here for bug/hotfix 12353 — should be handled in Rosettian. phoneDto.PhoneProvSpec.SwitchId = (details.SwitchId ?? string.Empty).ToUpper(); //Commented out for 10/25 release - Do Not Delete //phoneDto.PhoneProvSpec.SIPUserName = details.SIPUserName; //phoneDto.PhoneProvSpec.SIPPassword = details.SIPPassword; if (details.RGPort == "None") { //Signals Rosettian to remove the equipmentId from Triad (null will cause Rosettian to ignore the field) phoneDto.PhoneProvSpec.EquipmentId = string.Empty; } else if (!String.IsNullOrWhiteSpace(details.RGSerialNumber) && !String.IsNullOrWhiteSpace(details.RGPort)) { phoneDto.PhoneProvSpec.EquipmentId = details.RGSerialNumber + details.RGPort; } else { phoneDto.PhoneProvSpec.EquipmentId = null; } //Commented out for 10/25 release - Do Not Delete //Double noOfDays = (details.InterceptExpireData != null && details.InterceptExpireData.HasValue) ? // (details.InterceptExpireData.Value - DateTime.Now).TotalDays : 0; //string huntingMasterTN = null; //if (!String.IsNullOrWhiteSpace(details.HuntingGroupPosition)) //{ // huntingMasterTN = String.Format("{0}:{1}", details.HuntingMasterTN, details.HuntingGroupPosition); //} //else //{ // huntingMasterTN = details.HuntingMasterTN ?? string.Empty; //} //// Map metaswitch fields if they exist //var metaSwitchFields = phoneDto.PhoneProvSpec.SwitchFields as MetaSwitchFieldsDto; //if (metaSwitchFields == null) //{ // metaSwitchFields = new MetaSwitchFieldsDto(); //} //metaSwitchFields.HuntingMasterTN = huntingMasterTN??string.Empty; //metaSwitchFields.HuntingNoReplyTime = details.HuntingNoReplyTime??string.Empty; //metaSwitchFields.NumberBusy = details.NumberBusy??string.Empty; //metaSwitchFields.NumberDelayed = details.NumberDelayed??string.Empty; //metaSwitchFields.NumberSelective = details.NumberSelective??string.Empty; //metaSwitchFields.NumberUnavailable = details.NumberUnavailable??string.Empty; //metaSwitchFields.NumberUnconditional = details.NumberUnconditional??string.Empty; //metaSwitchFields.CFMaxSimForwardings = details.CFMaxSimForwardings??string.Empty; //metaSwitchFields.CFDelayNoReplyTime = details.CFDelayNoReplyTime??string.Empty; //metaSwitchFields.InterceptExpireData = (noOfDays == 0) // ? String.Empty // : Math.Ceiling(noOfDays).ToString(); //metaSwitchFields.RedirectNumber = details.RedirectNumber; //metaSwitchFields.ConnectAfterAnnounce = (details.ConnectAfterAnnounce != null && // details.ConnectAfterAnnounce.Equals("None")) // ? String.Empty // : details.ConnectAfterAnnounce; //metaSwitchFields.OffPremisesExt = details.OffPremisesExt; //metaSwitchFields.SIPMaxAppearance = details.SIPMaxAppearance??string.Empty; //metaSwitchFields.SIPMaxRefreshIntrvl = details.SIPMaxRefreshIntrvl??string.Empty; //phoneDto.PhoneProvSpec.SwitchFields = metaSwitchFields; }
public async Task <MainDetail> ExecuteLuisQuery(ILogger logger, ITurnContext turnContext, CancellationToken cancellationToken) { MainDetail detail = new MainDetail(); try { LuisRecognizer luisRecognizer = new LuisRecognizer(luisApplication); recognizerResult = await luisRecognizer.RecognizeAsync(turnContext, cancellationToken); //높은 점수의 의도 저장 var(intent, score) = recognizerResult.GetTopScoringIntent(); //대화의도에 따른 엔티티 저장 switch (intent) { case "버스": BusDetails busDetails = new BusDetails(); busDetails.intent = intent; busDetails = getLuisEntites(busDetails); detail = busDetails; break; case "미세먼지": DustDetails dustDetails = new DustDetails(); dustDetails.intent = intent; dustDetails = getDustLuisEntites(dustDetails); detail = dustDetails; break; case "장학제도": detail.intent = intent; break; case "전화번호": PhoneDetails phoneDetails = new PhoneDetails(); phoneDetails.intent = intent; phoneDetails = getPhoneEntites(phoneDetails); detail = phoneDetails; break; case "교수님": ProfessorsDetail pfDetail = new ProfessorsDetail(); pfDetail.intent = intent; pfDetail = getProfessorEntites(pfDetail); detail = pfDetail; break; case "트랙정보": TrackInfoCardDetail trackInfoCardDetail = new TrackInfoCardDetail(); trackInfoCardDetail.intent = intent; detail = trackInfoCardDetail; break; case "공지사항": NoticeDetail noticeDetail = new NoticeDetail(); noticeDetail.intent = intent; detail = noticeDetail; break; case "맛집": MatjeepchoochunDetail matjeepchoochunDetail = new MatjeepchoochunDetail(); matjeepchoochunDetail.intent = intent; matjeepchoochunDetail = getMatjeepchoochunEntites(matjeepchoochunDetail); detail = matjeepchoochunDetail; break; case "학식메뉴": detail.intent = intent; break; case "로그인": MainDetail loginDetail = new MainDetail(); loginDetail.intent = intent; detail = loginDetail; break; case "시간표": MainDetail timeDetail = new MainDetail(); timeDetail.intent = intent; detail = timeDetail; break; case "열람실": MainDetail seatDetail = new MainDetail(); seatDetail.intent = intent; detail = seatDetail; break; } } catch (Exception e) { await turnContext.SendActivityAsync(MessageFactory.Text("예기치 못한 오류가 발생하였습니다. 다시 시도해주십시오\n" + e.Message), cancellationToken); } return(detail); }
private PhoneDetails getPhoneEntites(PhoneDetails phoneDetails) { phoneDetails.Name = recognizerResult.Entities["부서"]?.FirstOrDefault()?.ToString().Replace(" ", ""); return(phoneDetails); }
/// <summary> /// Updates the phone details. /// </summary> /// <param name="subId">The sub identifier.</param> /// <param name="phoneDetails">The phone details.</param> /// <param name="userDto">The user dto.</param> /// <returns></returns> /// <exception cref="BusinessFacadeFaultException"> /// </exception> public bool UpdatePhoneDetails(string subId, PhoneDetails phoneDetails, UserDto userDto) { PhoneDto selectedPhone = null; var phones = _rosettianService.LoadSubscriberPhones(subId, userDto); if (phones != null && phones.Any()) { selectedPhone = phones.FirstOrDefault(phone => phone.PhoneNumber == phoneDetails.TN); } if (selectedPhone == null) { throw new BusinessFacadeFaultException { MessageDetail = @"TN not found." }; } selectedPhone.Update(phoneDetails); if (!_rosettianService.UpdateSubscriberPhone(subId, selectedPhone, userDto)) { throw new BusinessFacadeFaultException { MessageDetail = String.Format(@"Update subscriber phone: {0} failed.", selectedPhone) }; } return true; }
public static void UpdatePhoneBookDetails(PhoneDetails phoneDetail) { PhoneBookDL.AddUpdatePhoneBookDetails(phoneDetail); }