private void InitializePage() { try { btnSave.Text = Language.GetString(btnSave.Text); btnSave.Attributes["onclick"] = "return validateRequiredFields();"; foreach (PhoneBookGroupType type in Enum.GetValues(typeof(PhoneBookGroupType))) { if (type != PhoneBookGroupType.Vas) { drpType.Items.Add(new ListItem(Language.GetString(type.ToString()), ((int)type).ToString())); } } Common.PhoneBook phoneBook = Facade.PhoneBook.Load(PhoneBookGuid); drpType.SelectedValue = phoneBook.Type.ToString(); txtName.Text = phoneBook.Name; if (phoneBook.Type == (int)PhoneBookGroupType.Vas) { txtName.Enabled = false; drpType.Enabled = false; btnSave.Enabled = false; } } catch (Exception ex) { ShowMessageBox(ex.Message, string.Empty, "danger"); } }
//public static string GetPhoneBookName(Guid guid) //{ // Business.PhoneBook phoneBookController = new Business.PhoneBook(); // return phoneBookController.GetPhoneBookName(guid); //} public static Common.PhoneBook Load(Guid phoneBookGuid) { Business.PhoneBook phoneBookController = new Business.PhoneBook(); Common.PhoneBook phoneBook = new Common.PhoneBook(); phoneBookController.Load(phoneBookGuid, phoneBook); return(phoneBook); }
protected void btnSave_Click(object sender, EventArgs e) { Common.PhoneBook phoneBook = new Common.PhoneBook(); try { phoneBook.PhoneBookGuid = PhoneBookGuid; phoneBook.Type = Helper.GetByte(drpType.SelectedValue); phoneBook.ServiceId = txtServiceId.Text; phoneBook.VASRegisterKeys = txtRegisterKeys.Text; phoneBook.VASUnsubscribeKeys = txtUnsubscribeKeys.Text; DataTable dtUser = Facade.User.GetUser(txtOwner.Text); phoneBook.AlternativeUserGuid = dtUser.Rows.Count > 0 ? Helper.GetGuid(dtUser.Rows[0]["Guid"]) : Guid.Empty; if (!Facade.PhoneBook.UpdateVasSetting(phoneBook)) { throw new Exception(Language.GetString("ErrorRecord")); } ShowMessageBox(Language.GetString("InsertRecord"), string.Empty, "success"); } catch (Exception ex) { ShowMessageBox(ex.Message, string.Empty, "danger"); } }
//public string GetPhoneBookName(Guid guid) //{ // DataTable dataTable = base.FetchDataTable("Select * FROM PhoneBooks WHERE [Guid]=@Guid", "@Guid", guid); // return dataTable.Rows.Count == 0 ? string.Empty : Helper.GetString(dataTable.Rows[0]["Name"]); //} public bool UpdateVasSetting(Common.PhoneBook phoneBook) { try { return(base.ExecuteSPCommand("UpdateVasSetting", "@Guid", phoneBook.PhoneBookGuid, "@Type", phoneBook.Type, "@ServiceId", phoneBook.ServiceId, "@AlternativeUserGuid", phoneBook.AlternativeUserGuid, "@VASRegisterKeys", phoneBook.VASRegisterKeys, "@VASUnsubscribeKeys", phoneBook.VASUnsubscribeKeys)); } catch (Exception ex) { throw ex; } }
public static bool EditItemInPhoneBook(Common.PhoneBook phoneBook) { Business.PhoneBook phoneBookController = new Business.PhoneBook(); try { if (!phoneBookController.UpdateName(phoneBook)) { throw new Exception(Language.GetString("ErrorRecord")); } return(true); } catch (Exception ex) { throw ex; } }
private void InitializePage() { btnSave.Text = Language.GetString(btnSave.Text); foreach (PhoneBookGroupType type in Enum.GetValues(typeof(PhoneBookGroupType))) { drpType.Items.Add(new ListItem(Language.GetString(type.ToString()), ((int)type).ToString())); } drpType.SelectedValue = Helper.GetString((int)PhoneBookGroupType.Vas); Common.PhoneBook phoneBook = Facade.PhoneBook.Load(PhoneBookGuid); drpType.SelectedValue = phoneBook.Type.ToString(); txtServiceId.Text = phoneBook.ServiceId; txtOwner.Text = Facade.User.GetUserName(phoneBook.AlternativeUserGuid); txtRegisterKeys.Text = phoneBook.VASRegisterKeys; txtUnsubscribeKeys.Text = phoneBook.VASUnsubscribeKeys; }
public HttpResponseMessage AddGroup(PhoneBookModel phonebookInfo) { Common.PhoneBook phoneBook = new Common.PhoneBook(); PhoneBookResponseModel phonebookResponse = new PhoneBookResponseModel(); List <PhoneBookResponseModel> lstGroups = new List <PhoneBookResponseModel>(); var principal = Thread.CurrentPrincipal; if (!principal.Identity.IsAuthenticated) { throw new BusinessException(HttpStatusCode.Accepted, ErrorCode.AccountIsInvalid, Language.GetString("AccountIsInvalid")); } if (string.IsNullOrEmpty(phonebookInfo.Name)) { throw new BusinessException(HttpStatusCode.Accepted, ErrorCode.BadRequest, Language.GetString("BadRequest")); } Common.User userInfo = ((MyPrincipal)principal).UserDetails; phoneBook.Name = phonebookInfo.Name; phoneBook.ParentGuid = Guid.Empty; phoneBook.IsPrivate = false; phoneBook.UserGuid = userInfo.UserGuid; phoneBook.CreateDate = DateTime.Now; phoneBook.Type = (int)PhoneBookGroupType.Normal; Guid guid = Facade.PhoneBook.InsertItemInPhoneBook(phoneBook); phonebookResponse.Name = phoneBook.Name; phonebookResponse.PhoneBookGuid = guid; lstGroups.Add(phonebookResponse); PhoneBookResponse response = new PhoneBookResponse(); response.IsSuccessful = true; response.PhoneBooks = lstGroups; return(Request.CreateResponse(HttpStatusCode.OK, response)); }
public static Guid InsertItemInPhoneBook(Common.PhoneBook phoneBook) { Business.PhoneBook phoneBookController = new Business.PhoneBook(); Business.User userController = new Business.User(); Common.User user = new Common.User(); try { //if (!phoneBookController.CheckingName(phoneBook.Name, phoneBook.UserGuid)) // return Guid.Empty; userController.Load(phoneBook.UserGuid, user); phoneBook.AdminGuid = user.IsAdmin ? phoneBook.UserGuid : user.ParentGuid; phoneBook.CreateDate = DateTime.Now; phoneBook.IsPrivate = false; return(phoneBookController.Insert(phoneBook)); } catch (Exception ex) { throw ex; } }
public bool UpdateName(Common.PhoneBook phoneBook) { return(base.ExecuteSPCommand("UpdateName", "@Guid", phoneBook.PhoneBookGuid, "@Name", phoneBook.Name)); }
public static bool UpdateVasSetting(Common.PhoneBook phoneBook) { Business.PhoneBook phoneBookController = new Business.PhoneBook(); return(phoneBookController.UpdateVasSetting(phoneBook)); }