本文整理汇总了C#中Contact.Save方法的典型用法代码示例。如果您正苦于以下问题:C# Contact.Save方法的具体用法?C# Contact.Save怎么用?C# Contact.Save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Contact
的用法示例。
在下文中一共展示了Contact.Save方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HomeModule
public HomeModule()
{
Get["/"] = _ => {
return View["index.cshtml"];
};
Get["/contacts"] = _ => {
List<Contact> allContacts = Contact.GetAll();
return View["contacts.cshtml", allContacts];
};
Get["/contacts/new"] = _ => {
List<Contact> allContacts = Contact.GetAll();
return View["contact_form.cshtml", allContacts];
};
Post["/contact_created"] = _ => {
Contact newContact = new Contact(Request.Form["new-name"], Request.Form["new-phone"], Request.Form["new-address"]);
newContact.Save();
return View["contact_created.cshtml", newContact];
};
Post["/contacts_deleted"] = _ => {
Contact.ClearAll();
return View["contacts_deleted.cshtml"];
};
Get["/contacts/{id}"] = parameters => {
Contact contact = Contact.Find(parameters.id);
return View["/contact_created.cshtml", contact];
};
}
示例2: HomeModule
public HomeModule()
{
Get["/"] = _ =>{
return View["index.cshtml"];
};
Get["/add_new_contact"] = _ =>{
return View["add_new_contact.cshtml"];
};
Post["/contact_added"] = _ =>{
Contact oneContact = new Contact(Request.Form["name"], Request.Form["address"], Request.Form["phone"]);
oneContact.Save();
return View["/contact_created.cshtml", oneContact];
};
Get["/all_contacts"] = _ =>{
List<Contact> allContacts = Contact.GetAll();
return View["all_contacts.cshtml",allContacts];
};
Post["/contacts_cleared"] = _ =>{
Contact.DeleteAll();
return View["contacts_deleted.cshtml"];
};
}
示例3: CreateContact
//.........这里部分代码省略.........
c.Surname = strCtctSurname;
c.FileAsMapping = FileAsMapping.SurnameCommaGivenName;
//add company name if supplied
if (strCtctCompanyName.Length > 0)
c.CompanyName = strCtctCompanyName;
//add suppied phone numbers
if (strCtctHomePhone.Length > 0)
c.PhoneNumbers[PhoneNumberKey.HomePhone] = strCtctHomePhone;
if (strCtctWorkPhone.Length > 0)
c.PhoneNumbers[PhoneNumberKey.BusinessPhone] = strCtctWorkPhone;
if (strCtctMobilePhone.Length > 0)
c.PhoneNumbers[PhoneNumberKey.MobilePhone] = strCtctMobilePhone;
//add supplied email addresses
if (emlCtctEmail1.Length > 0)
c.EmailAddresses[EmailAddressKey.EmailAddress1] = new EmailAddress(emlCtctEmail1);
if (emlCtctEmail2.Length > 0)
c.EmailAddresses[EmailAddressKey.EmailAddress2] = new EmailAddress(emlCtctEmail2);
if (emlCtctEmail3.Length > 0)
c.EmailAddresses[EmailAddressKey.EmailAddress3] = new EmailAddress(emlCtctEmail3);
//Home address
int homeAddrLength = 0;
homeAddrLength += strCtctHomeAddrStreet.Length;
homeAddrLength += strCtctHomeAddrCity.Length;
homeAddrLength += strCtctHomeAddrStateAbbr.Length;
homeAddrLength += strCtctHomeAddrPostalCode.Length;
homeAddrLength += strCtctHomeAddrCountry.Length;
if (homeAddrLength > 0)
{
PhysicalAddressEntry paEntry1 = new PhysicalAddressEntry();
//add whichever fields are supplied
if (strCtctHomeAddrStreet.Length > 0)
paEntry1.Street = strCtctHomeAddrStreet;
if (strCtctHomeAddrCity.Length > 0)
paEntry1.City = strCtctHomeAddrCity;
if (strCtctHomeAddrStateAbbr.Length > 0)
paEntry1.State = strCtctHomeAddrStateAbbr;
if (strCtctHomeAddrPostalCode.Length > 0)
paEntry1.PostalCode = strCtctHomeAddrPostalCode;
if (strCtctHomeAddrCountry.Length > 0)
paEntry1.CountryOrRegion = strCtctHomeAddrCountry;
c.PhysicalAddresses[PhysicalAddressKey.Home] = paEntry1;
}
//Work address
int workAddrLength = 0;
workAddrLength += strCtctWorkAddrStreet.Length;
workAddrLength += strCtctWorkAddrCity.Length;
workAddrLength += strCtctWorkAddrStateAbbr.Length;
workAddrLength += strCtctWorkAddrPostalCode.Length;
workAddrLength += strCtctWorkAddrCountry.Length;
if (workAddrLength > 0)
{
PhysicalAddressEntry paEntry2 = new PhysicalAddressEntry();
//add whichever fields are supplied
if (strCtctWorkAddrStreet.Length > 0)
paEntry2.Street = strCtctWorkAddrStreet;
if (strCtctWorkAddrCity.Length > 0)
paEntry2.City = strCtctWorkAddrCity;
if (strCtctWorkAddrStateAbbr.Length > 0)
paEntry2.State = strCtctWorkAddrStateAbbr;
if (strCtctWorkAddrPostalCode.Length > 0)
paEntry2.PostalCode = strCtctWorkAddrPostalCode;
if (strCtctWorkAddrCountry.Length > 0)
paEntry2.CountryOrRegion = strCtctWorkAddrCountry;
c.PhysicalAddresses[PhysicalAddressKey.Business] = paEntry2;
}
//save the contact
c.Save(WellKnownFolderName.Contacts);
rsp.SimpleData = c.Id.UniqueId;
}
catch (Exception e)
{
if (!(int.TryParse(e.Message, out rsp.StatusCode)))
{
//if the parsing fails, then set a default value of 500
rsp.StatusCode = 500;
}
rsp.Msg = e.Message;
success = false;
miscData = "{ \"ErrMsg\":\"" + rsp.Msg + "\" }";
rsp.StackTrace = e.StackTrace;
if (e.InnerException != null) { rsp.InnerException = e.InnerException.ToString(); }
}
//audit
addAuditLog(apiKey, emlUserAddress, "CreateContact", success, miscData);
return rsp;
}
示例4: Create
public static ReturnObject Create(HttpContext context, string email, string first_name, string last_name, string phone_number, string message = null)
{
var provider = Security.GetCurrentProvider();
var providerProfile = ProviderUser.FindByProvider(provider).FirstOrDefault();
if( provider == null || string.IsNullOrEmpty(email) )
return new ReturnObject() { Error = true, Message = "Invalid Request." };
var contact = new Contact
{
FirstName = first_name,
LastName = last_name,
Email = email,
Phone = phone_number,
Fax = null
};
contact.Save();
var address = new Address
{
Street1 = string.Empty,
Street2 = null,
City = string.Empty,
State = string.Empty,
Zip = string.Empty,
Country = string.Empty
};
address.Save();
var prescriberProf = new PrescriberProfile
{
Guid = Guid.NewGuid(),
ProviderID = provider.ID.Value,
ContactID = contact.ID.Value,
AddressID = address.ID.Value,
Expires = DateTime.Now.AddYears(1),
PrimaryFacilityID = providerProfile.PrimaryFacilityID,
OrganizationId = providerProfile.OrganizationID,
Deleted = false,
};
prescriberProf.Save();
var data = new Dictionary<string, object> {
{"Message", (message != null)? message : "You have been invited to use the REMS Logic system. Please click the link below to complete your profile"},
{"Token", prescriberProf.Guid},
{"Year", DateTime.Now.Year.ToString()},
{"EmailAddress", email}
};
var overrides = new Framework.Email.TemplateOverrides {
To = new [] { new MailAddress(email) }
};
Email.SendTemplate("PrescriberInvite", data, overrides);
return new ReturnObject
{
Result = prescriberProf,
Actions = new List<ReturnActionObject>(new ReturnActionObject[] {
new ReturnActionObject { Type = "back" }
}),
Growl = new ReturnGrowlObject
{
Type = "default",
Vars = new ReturnGrowlVarsObject
{
text = "Your invite has been sent",
title = "Prescriber Invited"
}
}
};
}
示例5: SaveToDb
//数据持久化
internal static void SaveToDb(ContactInfo pContactInfo, Contact pContact,bool pIsNew)
{
pContact.ContactId = pContactInfo.contactId;
pContact.Mobile = pContactInfo.mobile;
pContact.Officephone = pContactInfo.officephone;
pContact.PhoneExt = pContactInfo.phoneExt;
pContact.Homephone = pContactInfo.homephone;
pContact.Email = pContactInfo.email;
pContact.IsNew=pIsNew;
string UserName = SubsonicHelper.GetUserName();
try
{
pContact.Save(UserName);
}
catch(Exception ex)
{
LogManager.getInstance().getLogger(typeof(ContactInfo)).Error(ex);
if(ex.Message.Contains("插入重复键"))//违反了唯一键
{
throw new AppException("此对象已经存在");//此处等待优化可以从唯一约束中直接取出提示来,如果没有的话,默认为原始的出错提示
}
throw new AppException("保存失败");
}
pContactInfo.contactId = pContact.ContactId;
//如果缓存存在,更新缓存
if (CachedEntityCommander.IsTypeRegistered(typeof(ContactInfo)))
{
ResetCache();
}
}