public async Task <IActionResult> OnGetAsync(Guid?id) { if (id == null) { return(NotFound()); } Customer = await _context.Customers .Include(c => c.Person) .Include(c => c.CustomerCompany) .AsNoTracking().FirstOrDefaultAsync(m => m.Id == id); if (Customer == null) { return(NotFound()); } Person = Customer.Person; CustomerCompany = Customer.CustomerCompany; ApplicationUser applicationUser = await _userManager.FindByIdAsync(Person.ApplicationUserId); InputUser = new InputUser { Email = applicationUser.Email, PhoneNumber = applicationUser.PhoneNumber }; ViewData["IdDocumentTypeId"] = new SelectList(_context.DocumentTypes.AsNoTracking(), "Id", "Name", Person?.IdDocument?.DocumentTypeId); return(Page()); }
public void InvalidPut() { // Arrange bool res = false; SQLiteServiceBase db = new SQLiteServiceBase(); CustomerCompany obj = GetInvalidObject(); // Act try { int len = 0; if (db.GetCustomerCompanies() != null) { foreach (var c in db.GetCustomerCompanies()) { len++; } } if (len != 0) { db.Edit(len - 1, obj); } } catch (Exception) { res = true; } // Assert Assert.IsFalse(res); }
public async Task <IActionResult> OnPostCreatePersonAsync(Guid?customerCompanyId) { if (!ModelState.IsValid) { return(Page()); } Person.TenantId = _tenantProvider.Tenant.Id; Person.ApplicationUser.TenantId = _tenantProvider.Tenant.Id; _context.People.Add(Person); await _context.SaveChangesAsync(); if (!string.IsNullOrEmpty(Person.ApplicationUser.Email)) { await _userManager.SetUserNameAsync(Person.ApplicationUser, Person.ApplicationUser.Email); } await _userManager.AddPasswordAsync(Person.ApplicationUser, "1qaz@WSX"); // TODO: Кастыль!!! Add Password 1qaz@WSX await _userManager.SetLockoutEnabledAsync(Person.ApplicationUser, true); await _userManager.AddToRolesAsync(Person.ApplicationUser, new List <string> { "Customer" }); CustomerCompany = _context.CustomerCompanies.Find(customerCompanyId); return(Page()); }
public async Task <IActionResult> PutCustomerCompany(int id, CustomerCompany customerCompany) { if (id != customerCompany.Id) { return(BadRequest()); } _context.Entry(customerCompany).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CustomerCompanyExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public Dictionary <string, string> GetPaymentDictionary() { var dictionary = new Dictionary <string, string> { { "transaction_type", "sale" }, { "reference_number", Id.ToString() }, // use the actual id so we can find it easily { "amount", CalculatedTotal.ToString("F2") }, { "currency", "USD" }, { "transaction_uuid", Guid.NewGuid().ToString() }, { "signed_date_time", DateTime.UtcNow.ToString("yyyy-MM-dd'T'HH:mm:ss'Z'") }, { "unsigned_field_names", string.Empty }, { "locale", "en" }, { "bill_to_email", CustomerEmail }, { "bill_to_forename", CustomerName.SafeTruncate(60) }, { "bill_to_company_name", CustomerCompany.SafeRegexRemove().SafeTruncate(40) }, { "bill_to_address_country", "US" }, { "bill_to_address_state", "CA" } }; dictionary.Add("line_item_count", Items.Count.ToString("D")); for (var i = 0; i < Items.Count; i++) { dictionary.Add($"item_{i}_name", Items[i].Description); //dictionary.Add($"item_{i}_quantity", Items[i].Quantity.ToString()); dictionary.Add($"item_{i}_unit_price", Items[i].Total.ToString("F2")); } return(dictionary); }
public async Task <ActionResult <CustomerCompany> > PostCustomerCompany(CustomerCompany customerCompany) { _context.CustomerCompanies.Add(customerCompany); await _context.SaveChangesAsync(); return(CreatedAtAction("GetCustomerCompany", new { id = customerCompany.Id }, customerCompany)); }
public static bool ModifyCustomerCompany(CustomerCompany model) { string sql = string.Format(@"update {0} set [CompanyId]=@CompanyId,[CompanyName]=@CompanyName,[Name]=@Name,[City]=@City,[Address]=@Address,[Status]=@Status,[Infos]=@Infos,[IsDeleted]=@IsDeleted,[ModifyDate]=getdate(),[ModifyBy]=@ModifyBy, [BankName]=@BankName,[BankNo]=@BankNo,[Tax]=@Tax,[ContactName]=@ContactName,[ContactMobile]=@ContactMobile,[License]=@License where Id=@Id", TableName); return(DBAccess.ExecuteSqlWithEntity(sql, model)); }
public CustomerCompanyView(CustomerCompany input) { Mapper.CreateMap<CustomerCompany, CustomerCompanyView>(); Mapper.Map<CustomerCompany, CustomerCompanyView>(input, this); this.created = input.created.ToString().Replace('T', ' '); this.updated = input.updated.ToString().Replace('T', ' '); }
//reset all textbox public void Reset() { GetCustomerId(); CustomerName.ResetText(); CustomerCompany.ResetText(); CustomerPhn.ResetText(); CustomerTypeDD.SelectedIndex = -1; }
public CustomerCompanyView(CustomerCompany input) { Mapper.CreateMap <CustomerCompany, CustomerCompanyView>(); Mapper.Map <CustomerCompany, CustomerCompanyView>(input, this); this.created = input.created.ToString().Replace('T', ' '); this.updated = input.updated.ToString().Replace('T', ' '); }
public void addNewItem(CustomerCompany dataItem) { if (dataItem != null) { context.CustomerCompanies.Add(dataItem); context.SaveChanges(); } }
public void Delete(CustomerCompany ObjDelete) { var ObjToDelete = _context.CustomerCompanies.SingleOrDefault(m => m.CompanyID == ObjDelete.CompanyID && m.CompanyCode == ObjDelete.CompanyCode); if (ObjToDelete != null) { _context.CustomerCompanies.Remove(ObjToDelete); } }
public CustomerCompany convert(EntityFrameworkContext context) { var output = new CustomerCompany(); Mapper.CreateMap <CustomerPrivateView, CustomerPrivate>(); Mapper.Map <CustomerCompanyView, CustomerCompany>(this, output); return(output); }
public void DeleteCustomerCompany(int id) { CustomerCompany obj = dataBase.CustomerCompanies.Find(id); if (obj != null) { dataBase.CustomerCompanies.Remove(obj); Update(); } }
CustomerCompany GetInvalidObject() { CustomerCompany obj = new CustomerCompany(); obj.CompanyName = ""; obj.CreditLimitCurrency = ""; obj.CompanyCreditLimit = 100000000; return(obj); }
public ActionResult Save() { var userId = User.Identity.GetUserId(); var UserInfo = _unitOfWork.User.GetMyInfo(userId); CustomerCompany Obj = new CustomerCompany { CompanyCode = _unitOfWork.CustomerCompany.GetMaxSerial(UserInfo.fCompanyId) }; return(PartialView(Obj)); }
public void Update(CustomerCompany ObjUpdate) { var ObjToUpdate = _context.CustomerCompanies.SingleOrDefault(m => m.CompanyID == ObjUpdate.CompanyID && m.CompanyCode == ObjUpdate.CompanyCode); if (ObjToUpdate != null) { ObjToUpdate.CompanyName = ObjUpdate.CompanyName; ObjToUpdate.InsDateTime = ObjUpdate.InsDateTime; ObjToUpdate.InsUserID = ObjUpdate.InsUserID; } }
public void removeItem(int ID) { if (ID != 0) { CustomerCompany theDbRecord = context.CustomerCompanies.Find(ID); if (theDbRecord != null) { context.CustomerCompanies.Remove(theDbRecord); } } }
public IList <CustomerCompany> GetCustomersPaginatedList(CustomerCompany customer, int pageIndex, int pageSize, out int totalRows) { try { return(_customerService.GetCustomersPaginatedList(customer, pageIndex, pageSize, out totalRows)); } catch (Exception ex) { Log.Write(ex); throw; } }
public void UpdateCustomer(CustomerCompany customer) { try { _customerService.UpdateCustomer(customer); } catch (Exception ex) { Log.Write(ex); throw; } }
public async Task <IActionResult> OnPostAsync(Guid?personId, Guid?customerCompanyId) { if (!ModelState.IsValid) { return(Page()); } if (personId == null) { ModelState.AddModelError("Person", "Нужно выбрать или создать Физ. лицо!"); Person = null; CustomerCompany = _context.CustomerCompanies.Find(customerCompanyId); return(Page()); } ApplicationUser user = await _userManager.GetUserAsync(HttpContext.User); Guid manadgerId = _context.Managers.Where(m => m.Person.ApplicationUserId == user.Id).AsNoTracking().FirstOrDefault().Id; Customer customerCompany = new Customer { TenantId = _tenantProvider.Tenant.Id, ManagerId = manadgerId, PersonId = personId, CustomerCompanyId = customerCompanyId }; _context.Customers.Add(customerCompany); Customer customerPerson = new Customer { TenantId = _tenantProvider.Tenant.Id, ManagerId = manadgerId, PersonId = personId }; _context.Customers.Add(customerPerson); string returnPage = (string)TempData["ReturnPage"]; Guid orderId = (Guid)TempData["OrderId"]; var order = _context.Orders.IgnoreQueryFilters().FirstOrDefault(o => o.Id == orderId); if (order == null || order.TenantId != _tenantProvider.Tenant.Id || order.IsDeleted) { return(NotFound()); } order.CustomerId = customerCompany.Id; await _context.SaveChangesAsync(); return(RedirectToPage(returnPage, "", new { id = orderId }, "Customers")); }
public string AddCustomer(CustomerCompany customer) { try { return(_customerService.AddCustomer(customer)); } catch (Exception ex) { Log.Write(ex); throw; } }
public CustomerCompany GetCustomerCompanyId(int id) { CustomerCompany obj = null; foreach (CustomerCompany o in dataBase.CustomerCompanies) { if (o.CompanyId == id) { obj = o; break; } } return(obj); }
public JsonResult SaveCompanyInfo(CustomerCompany model) { var info = new ResultInfo(); var account = CookieOperate.AccountCookie; var data = CustomerCompanyDBOperate.GetCompanyByMember(account.AccountId); if (model.Name != "") { data.Name = model.Name; } if (model.Tax != "") { data.Tax = model.Tax; } if (model.BankName != "") { data.BankName = model.BankName; } if (model.BankNo != "") { data.BankNo = model.BankNo; } if (model.License != "") { data.License = model.License; } if (model.ContactName != "") { data.ContactName = model.ContactName; } if (model.ContactMobile != "") { data.ContactMobile = model.ContactMobile; } if (model.Address != "") { data.Address = model.Address; } account.AccountName = model.Name; info.IsSuccess = CustomerCompanyDBOperate.ModifyCustomerCompany(data); CookieOperate.AccountCookie = account; if (info.IsSuccess) { info.Message = "修改成功"; } else { info.Message = "修改失败"; } return(Json(info)); }
public string AddCustomer(CustomerCompany customer) { customer.Id = Guid.NewGuid().ToString(); customer.CreationDate = DateTime.Now; _customerCompanyRepository.Add(customer); customer.Contacts.ForEach(c => { c.CustomerId = customer.Id; //c.ContactId = customer.ContactId; c.Id = Guid.NewGuid().ToString(); c.CreationDate = DateTime.Now; }); //_contactRepository.InsertContacts(customer.Contacts); return(customer.Id); }
// POST api/CustomerCompanies public IHttpActionResult Post([FromBody] CustomerCompany value) { try { db.Add(value); } catch (Exception ex) { ModelState.AddModelError(nameof(Country), ex.Message); return(BadRequest(ModelState)); } return(Ok()); }
// PUT api/CustomerCompanies/{id} public IHttpActionResult Put(int id, [FromBody] CustomerCompany value) { try { _db.Edit(id, value); } catch (Exception ex) { ModelState.AddModelError(nameof(CustomerCompany), ex.Message); return(BadRequest(ModelState)); } return(Ok()); }
public async Task <IActionResult> OnGetAsync(Guid?id) { if (id == null) { return(NotFound()); } CustomerCompany = await _context.CustomerCompanies .Include(c => c.Person).FirstOrDefaultAsync(m => m.Id == id); if (CustomerCompany == null) { return(NotFound()); } return(Page()); }
public async Task <IActionResult> OnGetAsync(Guid?id) { if (id == null) { return(NotFound()); } CustomerCompany = await _context.CustomerCompanies .Include(c => c.Person).FirstOrDefaultAsync(m => m.Id == id); if (CustomerCompany == null) { return(NotFound()); } //ViewData["PersonId"] = new SelectList(_context.People, "Id", "Id"); return(Page()); }
public async Task <IActionResult> OnPostAsync(Guid?id) { if (id == null) { return(NotFound()); } CustomerCompany = await _context.CustomerCompanies.FindAsync(id); if (CustomerCompany != null) { CustomerCompany.IsDeleted = true; await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public void updateItem(CustomerCompany dataItem) { if (dataItem != null) { CustomerCompany theDbRecord = context.CustomerCompanies.Find(dataItem.ID); if (theDbRecord != null) { theDbRecord.Title = dataItem.Title; theDbRecord.Descriptions = dataItem.Descriptions; theDbRecord.TelephoneNumberI = dataItem.TelephoneNumberI; theDbRecord.TelephoneNumberII = dataItem.TelephoneNumberII; theDbRecord.TelephoneNumberIII = dataItem.TelephoneNumberIII; theDbRecord.EmailAddress = dataItem.EmailAddress; context.SaveChanges(); } } }
public CustomerCompany convert(EntityFrameworkContext context) { var output = new CustomerCompany(); Mapper.CreateMap<CustomerPrivateView, CustomerPrivate>(); Mapper.Map<CustomerCompanyView, CustomerCompany>(this, output); return output; }