Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 3
0
        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());
        }
Ejemplo n.º 4
0
        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());
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
        public async Task <ActionResult <CustomerCompany> > PostCustomerCompany(CustomerCompany customerCompany)
        {
            _context.CustomerCompanies.Add(customerCompany);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetCustomerCompany", new { id = customerCompany.Id }, customerCompany));
        }
Ejemplo n.º 7
0
        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', ' ');
        }
Ejemplo n.º 9
0
        //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();
     }
 }
Ejemplo n.º 12
0
        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);
        }
Ejemplo n.º 16
0
        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));
        }
Ejemplo n.º 17
0
        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);
         }
     }
 }
Ejemplo n.º 19
0
 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;
     }
 }
Ejemplo n.º 20
0
 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"));
        }
Ejemplo n.º 22
0
 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);
        }
Ejemplo n.º 24
0
        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));
        }
Ejemplo n.º 25
0
 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);
 }
Ejemplo n.º 26
0
        // 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());
        }
Ejemplo n.º 27
0
        // 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());
        }
Ejemplo n.º 28
0
        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());
        }
Ejemplo n.º 29
0
        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());
        }
Ejemplo n.º 30
0
        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;
        }