public bool add(ClientContactInfo clientContact) { var tmp = new ComMails(); var rnd = new Random(); var pwd = _passwordTools.passwordGen(10); clientContact.Username = clientContact.FirstName[0] + clientContact.LastName + rnd.Next(clientContact.LastName.Length * 1000).ToString(); clientContact.Password = _passwordTools.passwordHash(pwd); tmp.Email = new List <string>(); tmp.Email.Add(clientContact.Email); tmp.Message = "Please find below, your credentials to NRP Portal:<br/>Sign in as Client<br/>"; tmp.Message += "Username " + clientContact.Username + "<br/>Password: " + pwd; _comMail.SendMailToPar(tmp); try { clientContact.Date = DateTime.Now; _context.ClientContactInfos.Add(clientContact); _context.SaveChanges(); } catch (Exception e) { Console.WriteLine(e.StackTrace); return(false); } return(true); }
//[Authorize(Roles = "ClientContact:12, ClientContact:13, ClientContact:15, ClientContact:16")] public IActionResult Create([FromBody] ClientContactInfo clientContact) { var res = _clientContact.add(clientContact); if (res == true) { return(CreatedAtRoute("ClientContactById", new { Controller = "ClientContact", id = clientContact.ClientContactInfoId }, clientContact)); } return(StatusCode(500)); }
private int ClientContactInfoFaker() { var clientContactInfo = new ClientContactInfo() { EMail = Faker.InternetFaker.Email(), TelephoneNumber = Faker.PhoneFaker.Phone() }; context.ClientContactInfos.AddOrUpdate(clientContactInfo); context.SaveChanges(); return(clientContactInfo.Id); }
public bool update(int id, ClientContactInfo clientContact) { clientContact.ClientContactInfoId = id; try { _context.ClientContactInfos.Update(clientContact); _context.SaveChanges(); } catch (Exception e) { Console.WriteLine(e.StackTrace); return(false); } return(true); }
private void FillFromFreedomDetails(DeliveryParameters deliveryParameters) { var orderApiClient = ByDesignAPIHelper.CreateOrderAPIClient(); var orderDetailsResponse = orderApiClient.GetOrderDetailsInfo_V2(orderApiClient.CreateCredentials(), deliveryParameters.OrderId); if (orderDetailsResponse.Success == 0) { throw new InvalidOperationException(orderDetailsResponse.Message); } List <DeliveryItem> deliveryItems = new List <DeliveryItem>(); foreach (var responseItem in orderDetailsResponse.OrderDetailsResponse) { DeliveryItem deliveryItem = new DeliveryItem { ItemId = responseItem.ProductID, Name = responseItem.Description, Quantity = responseItem.Quantity, Cost = decimal.Parse(responseItem.TaxableAmount, CultureInfo.InvariantCulture), PayCost = decimal.Parse(responseItem.TaxableAmount, CultureInfo.InvariantCulture) }; FillItemCosts(deliveryItem); deliveryItems.Add(deliveryItem); } var responseOrderInfo = orderApiClient.GetOrderInfo_V2(orderApiClient.CreateCredentials(), deliveryParameters.OrderId); if (responseOrderInfo.Success == 0) { throw new InvalidOperationException(responseOrderInfo.Message); } OrderClientInfo orderClientInfo = OrderClientInfo.ExtractFromOrder(responseOrderInfo); // extracting order client info var onlineApiClient = ByDesignAPIHelper.CreateOnlineAPIClient(); ClientContactInfo contactInfo = new ClientContactInfo(); if (orderClientInfo.IsRep) { var responseRepInfo = onlineApiClient.GetRepInfo_V3(onlineApiClient.CreateCredentials(), orderClientInfo.ClientNumber); if (responseRepInfo.Success == 0) { throw new InvalidOperationException(responseOrderInfo.Message); } contactInfo.FirstName = responseRepInfo.Firstname; contactInfo.LastName = responseRepInfo.Lastname; contactInfo.Email = responseRepInfo.Email; contactInfo.Phone = responseRepInfo.Phone1; } else { var responseCustInfo = onlineApiClient.GetCustomerInfo_v3(onlineApiClient.CreateCredentials(), orderClientInfo.ClientNumber); if (responseCustInfo.Success == 0) { throw new InvalidOperationException(responseOrderInfo.Message); } contactInfo.FirstName = responseCustInfo.FirstName; contactInfo.LastName = responseCustInfo.LastName; contactInfo.Email = responseCustInfo.Email; contactInfo.Phone = responseCustInfo.Phone1; } Address deliveryAddress = new Address { PostIndex = responseOrderInfo.ShipPostalCode, Country = responseOrderInfo.ShipCountry, State = responseOrderInfo.ShipState, Place = responseOrderInfo.ShipCity, Street_1 = responseOrderInfo.ShipStreet1, Street_2 = responseOrderInfo.ShipStreet2 }; DeliveryRecipient recipient = new DeliveryRecipient { FullName = responseOrderInfo.ShipName1, Phone = responseOrderInfo.ShipPhone, Email = responseOrderInfo.ShipEmail }; deliveryParameters.Items = deliveryItems.ToArray(); deliveryParameters.DeliveryAddress = deliveryAddress; deliveryParameters.Recipient = recipient; deliveryParameters.ContactInfo = contactInfo; var responseTotals = orderApiClient.GetTotals(orderApiClient.CreateCredentials(), deliveryParameters.OrderId); if (responseTotals.Success == 0) { throw new InvalidOperationException(responseTotals.Message); } deliveryParameters.ShippingTotal = decimal.Parse(responseTotals.ShippingTotal, CultureInfo.InvariantCulture); }
//[Authorize(Roles = "ClientContact:15, ClientContact:16, ClientContact:10, ClientContact:11")] public IActionResult Update(int id, [FromBody] ClientContactInfo clientContact) { return(_clientContact.update(id, clientContact) ? new NoContentResult() : StatusCode(500)); }