public async Task <ActionResult <ContactAccountModel> > ContactAccountAsync(int accountingNumber, string accountNumber, DateTimeOffset?statusDate = null) { if (string.IsNullOrWhiteSpace(accountNumber)) { throw new IntranetExceptionBuilder(ErrorCode.ValueCannotBeNullOrWhiteSpace, nameof(accountNumber)) .WithValidatingType(typeof(string)) .WithValidatingField(nameof(accountNumber)) .Build(); } IGetContactAccountQuery query = new GetContactAccountQuery { AccountingNumber = accountingNumber, AccountNumber = accountNumber, StatusDate = statusDate?.LocalDateTime.Date ?? DateTime.Today }; IContactAccount contactAccount = await _queryBus.QueryAsync <IGetContactAccountQuery, IContactAccount>(query); if (contactAccount == null) { throw new IntranetExceptionBuilder(ErrorCode.ValueShouldBeKnown, nameof(accountNumber)) .WithValidatingType(typeof(string)) .WithValidatingField(nameof(accountNumber)) .Build(); } ContactAccountModel contactAccountModel = _accountingModelConverter.Convert <IContactAccount, ContactAccountModel>(contactAccount); return(Ok(contactAccountModel)); }
// GET: NewContactAccount public async Task <ActionResult> Index(string FirstName, string LastName, string Phone, string EmailAddress, string portalRegRequestId, bool ajax = false, bool fromProtal = false) { ClaimTeamLoginModel client = (ClaimTeamLoginModel)Session[SessionHelper.claimTeamLogin]; string UserId = client.UserId; ContactAccountModel model = new ContactAccountModel(); model.PickTitle = await GetPickListData("Title"); model.PickTypes = await GetPickListData("Account Type"); model.AccountManagerId = UserId; ViewBag.Message = ""; if (fromProtal) { model.Contact = FirstName + " " + LastName; if (Phone != null && Phone != "null") { model.Phone = Phone; } if (EmailAddress != null && EmailAddress != "null") { model.Email = EmailAddress; } if (portalRegRequestId != null && portalRegRequestId != "null") { model.portalRegRequestId = portalRegRequestId; } model.FromProtal = true; } else { model.FromProtal = false; } if (ajax) { return(Json(new { Success = true }, JsonRequestBehavior.AllowGet)); } //Get Suburbs pickListServices = new PicklistServicecs(); model.PropertySuburbList = pickListServices.GetPickListItems("H_Suburbs"); model.PropertySuburbList.Insert(0, new PicklistItem()); //Get Suburbs PropertyStateList = new PicklistServicecs(); model.PropertyStateList = pickListServices.GetPickListItems("H_State"); model.PropertyStateList.Insert(0, new PicklistItem()); return(View(model)); }
public async Task ContactAccountAsync_WhenContactAccountWasReturnedFromQueryBus_ReturnsOkObjectResultWhereValueIsContactAccountModelMatchingContactAccountFromQueryBus() { string accountNumber = _fixture.Create <string>(); IContactAccount contactAccount = _fixture.BuildContactAccountMock(accountNumber: accountNumber).Object; Controller sut = CreateSut(contactAccount: contactAccount); OkObjectResult result = (OkObjectResult)(await sut.ContactAccountAsync(_fixture.Create <int>(), _fixture.Create <string>())).Result; ContactAccountModel contactAccountModel = (ContactAccountModel)result.Value; Assert.That(contactAccountModel, Is.Not.Null); Assert.That(contactAccountModel.AccountNumber, Is.EqualTo(accountNumber)); }
public async Task <ActionResult> Index(ContactAccountModel model) { ClaimTeamLoginModel client = (ClaimTeamLoginModel)Session[SessionHelper.claimTeamLogin]; string UserId = client.UserId; ContactAccountRepo conrepo = new ContactAccountRepo(); var result = await conrepo.AddContactAccount(model, UserId); ContactAccountModel rmodel = new ContactAccountModel(); rmodel.PickTitle = await GetPickListData("Title"); rmodel.PickTypes = await GetPickListData("Account Type"); rmodel.AccountManagerId = UserId; pickListServices = new PicklistServicecs(); rmodel.PropertySuburbList = pickListServices.GetPickListItems("H_Suburbs"); rmodel.PropertySuburbList.Insert(0, new PicklistItem()); //Get Suburbs PropertyStateList = new PicklistServicecs(); rmodel.PropertyStateList = pickListServices.GetPickListItems("H_State"); rmodel.PropertyStateList.Insert(0, new PicklistItem()); if (result) { ViewBag.Message = "Success: Save successful"; } else { ViewBag.Message = "Error: Save unsuccessful"; } ModelState.Clear(); if (model.FromProtal) { return(RedirectToAction("AdminList", "AdminList")); } else { return(RedirectToAction("Index", "AccountList")); //return View(rmodel); } //return RedirectToAction("Index"); }
public async Task <bool> AddContactAccount(ContactAccountModel model, string userId) { var result = false; if (model != null) { string SiteUrl = ConfigurationManager.AppSettings["apiurl"]; var json = JsonConvert.SerializeObject(model); string apiUrl = SiteUrl + "api/Account/CreateContactAccount"; using (HttpClient client = new HttpClient()) { using (var formData = new MultipartFormDataContent()) { client.BaseAddress = new Uri(apiUrl); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); var content = new StringContent(json, System.Text.Encoding.UTF8, "application/json"); var content2 = new StringContent(userId, System.Text.Encoding.UTF8, "application/json"); formData.Add(content, "contactAccountObjStr"); formData.Add(content2, "userId"); HttpResponseMessage response = await client.PostAsync(apiUrl, formData); if (response.IsSuccessStatusCode) { var data = await response.Content.ReadAsStringAsync(); result = Convert.ToBoolean(data); } } } if (model.FromProtal && model.portalRegRequestId != null) { TeamGetPortalRegistrationRepo teamGetPortalRegistrationRepo = new TeamGetPortalRegistrationRepo(); var rs = await teamGetPortalRegistrationRepo.TeamDiscardLoginRequest(model.portalRegRequestId); } } return(result); }