コード例 #1
0
ファイル: OrdersController.cs プロジェクト: Jason235/BOC
        private CompanyAndBtcFile GetFackCompanyAndBtcFile(long CurrentOrderID, string SendUserName, string CurrentUserName)
        {
            CompanyAndBtcFile lCompanyAndBtcFile = new CompanyAndBtcFile();

            BOC.Entities.Company TempCompany = _BOCWebDBContext.Companys.Where(e => e.LoginUserName == SendUserName).FirstOrDefault();
            lCompanyAndBtcFile.Company = new BOC.Entities.Company();

            if (TempCompany != null)
            {
                if (TempCompany.CompanyName != null && TempCompany.CompanyName != "")
                {
                    lCompanyAndBtcFile.Company.CompanyName = "******";
                }
                else
                {
                    lCompanyAndBtcFile.Company.CompanyName = "_none";
                }

                if (TempCompany.CompanyLocalName != null && TempCompany.CompanyLocalName != "")
                {
                    lCompanyAndBtcFile.Company.CompanyLocalName = "******";
                }
                else
                {
                    lCompanyAndBtcFile.Company.CompanyLocalName = "_none";
                }

                if (TempCompany.CompanyEmail != null && TempCompany.CompanyEmail != "")
                {
                    lCompanyAndBtcFile.Company.CompanyEmail = "******";
                }
                else
                {
                    lCompanyAndBtcFile.Company.CompanyEmail = "_none";
                }

                if (TempCompany.CompanyType != null && TempCompany.CompanyType != "")
                {
                    lCompanyAndBtcFile.Company.CompanyType = "******";
                }
                else
                {
                    lCompanyAndBtcFile.Company.CompanyType = "_none";
                }

                if (TempCompany.CompanyPhoneNumber != null && TempCompany.CompanyPhoneNumber != "")
                {
                    lCompanyAndBtcFile.Company.CompanyPhoneNumber = "******";
                }
                else
                {
                    lCompanyAndBtcFile.Company.CompanyPhoneNumber = "_none";
                }

                if (TempCompany.CompanyFaxNumber != null && TempCompany.CompanyFaxNumber != "")
                {
                    lCompanyAndBtcFile.Company.CompanyFaxNumber = "******";
                }
                else
                {
                    lCompanyAndBtcFile.Company.CompanyFaxNumber = "_none";
                }

                if (TempCompany.CompanyWebSite != null && TempCompany.CompanyWebSite != "")
                {
                    lCompanyAndBtcFile.Company.CompanyWebSite = "******";
                }
                else
                {
                    lCompanyAndBtcFile.Company.CompanyWebSite = "_none";
                }

                if (TempCompany.CompanyCountry != null && TempCompany.CompanyCountry != "")
                {
                    lCompanyAndBtcFile.Company.CompanyCountry = TempCompany.CompanyCountry;
                }
                else
                {
                    lCompanyAndBtcFile.Company.CompanyCountry = "_none";
                }

                if (TempCompany.CompanyProvince != null && TempCompany.CompanyProvince != "")
                {
                    if (lCompanyAndBtcFile.Company.CompanyCountry != "_china")
                    {
                        lCompanyAndBtcFile.Company.CompanyProvince = "******";
                    }
                    else
                    {
                        lCompanyAndBtcFile.Company.CompanyProvince = TempCompany.CompanyProvince;
                    }
                    //lCompanyAndBtcFile.Company.CompanyProvince = TempCompany.CompanyProvince;
                }
                else
                {
                    lCompanyAndBtcFile.Company.CompanyProvince = "_none";
                }

                if (TempCompany.CompanyAddress != null && TempCompany.CompanyAddress != "")
                {
                    lCompanyAndBtcFile.Company.CompanyAddress = "******";
                }
                else
                {
                    lCompanyAndBtcFile.Company.CompanyAddress = "_none";
                }

                BOC.Entities.ContactPerson TempContactPerson = TempCompany.ContactPersons.FirstOrDefault();
                lCompanyAndBtcFile.Company.ContactPersons = new List<BOC.Entities.ContactPerson>();
                BOC.Entities.ContactPerson lContactPerson = new BOC.Entities.ContactPerson();

                if (TempContactPerson != null)
                {
                    if (TempContactPerson.ContactPersonName != null && TempContactPerson.ContactPersonName != "")
                    {
                        lContactPerson.ContactPersonName = "******";
                    }
                    else
                    {
                        lContactPerson.ContactPersonName = "_none";
                    }

                    if(TempContactPerson.ContactPersonEnglishName != null && TempContactPerson.ContactPersonEnglishName != "")
                    {
                        lContactPerson.ContactPersonEnglishName = "******";
                    }
                    else
                    {
                        lContactPerson.ContactPersonEnglishName = "_none";
                    }

                    if (TempContactPerson.ContactPersonCellPhoneNumber != null && TempContactPerson.ContactPersonCellPhoneNumber != "")
                    {
                        lContactPerson.ContactPersonCellPhoneNumber = "******";
                    }
                    else
                    {
                        lContactPerson.ContactPersonCellPhoneNumber = "_none";
                    }
                }
                lCompanyAndBtcFile.Company.ContactPersons.Add(lContactPerson);
            }

            BOC.Entities.CompanyBtcFile lCompanyBtcFile = _BOCWebDBContext.CompanyBtcFiles.Where(e => e.CompanyName == SendUserName).FirstOrDefault();

            lCompanyAndBtcFile.CompanyBtcFile = new BOC.Entities.CompanyBtcFile();

            if (lCompanyBtcFile != null)
            {
                if (lCompanyBtcFile.CompanyName != null && lCompanyBtcFile.CompanyName != "")
                {
                    lCompanyAndBtcFile.CompanyBtcFile.CompanyName = "******";
                }
                else
                {
                    lCompanyAndBtcFile.CompanyBtcFile.CompanyName = "_none";
                }

                if (lCompanyBtcFile.CompanyBtCFile != null && lCompanyBtcFile.CompanyBtCFile != "")
                {
                    lCompanyAndBtcFile.CompanyBtcFile.CompanyBtCFile = "******";
                }
                else
                {
                    lCompanyAndBtcFile.CompanyBtcFile.CompanyBtCFile = "_none";
                }

                if (lCompanyBtcFile.CompanyLocalName != null && lCompanyBtcFile.CompanyLocalName != "")
                {
                    lCompanyAndBtcFile.CompanyBtcFile.CompanyLocalName = "******";
                }
                else
                {
                    lCompanyAndBtcFile.CompanyBtcFile.CompanyLocalName = "_none";
                }

                if (lCompanyBtcFile.CompanyType != null && lCompanyBtcFile.CompanyType != "")
                {
                    lCompanyAndBtcFile.CompanyBtcFile.CompanyType = lCompanyBtcFile.CompanyType;
                }
                else
                {
                    lCompanyAndBtcFile.CompanyBtcFile.CompanyType = "_none";
                }

                if (lCompanyBtcFile.CompanyYearFounded != null && lCompanyBtcFile.CompanyYearFounded != "")
                {
                    lCompanyAndBtcFile.CompanyBtcFile.CompanyYearFounded = "******";
                }
                else
                {
                    lCompanyAndBtcFile.CompanyBtcFile.CompanyYearFounded = "_none";
                }

                lCompanyAndBtcFile.CompanyBtcFile.CompanyLocalNameCeritificate = lCompanyBtcFile.CompanyLocalNameCeritificate;
                lCompanyAndBtcFile.CompanyBtcFile.CompanyNameCeritificate = lCompanyBtcFile.CompanyNameCeritificate;
                lCompanyAndBtcFile.CompanyBtcFile.CompanyTypeCeritificate = lCompanyBtcFile.CompanyTypeCeritificate;
                lCompanyAndBtcFile.CompanyBtcFile.CompanyYearFoundedCeritificate = lCompanyBtcFile.CompanyYearFoundedCeritificate;

            }
            else
            {
                lCompanyAndBtcFile.CompanyBtcFile.CompanyName = "_none";
                lCompanyAndBtcFile.CompanyBtcFile.CompanyBtCFile = "_none";
                lCompanyAndBtcFile.CompanyBtcFile.CompanyLocalName = "_none";
                lCompanyAndBtcFile.CompanyBtcFile.CompanyType = "_none";
                lCompanyAndBtcFile.CompanyBtcFile.CompanyYearFounded = "_none";
            }

            lCompanyAndBtcFile.CompanyBtcFileTradedList = new List<BOC.Entities.CompanyBtcFileTraded>();

            List<BOC.Entities.CompanyBtcFileTraded> lCompanyBtcFileTradeds = _BOCWebDBContext.CompanyBtcFileTradeds
                    .Where(e => e.CompanyName == SendUserName)
                    .OrderByDescending(e => e.TradeYear)
                    .ToList();

            int lLastTradeYear = -1;
            decimal lTotalTradeQuantity = 0;
            foreach (BOC.Entities.CompanyBtcFileTraded CompanyBtcFileTraded in lCompanyBtcFileTradeds)
            {
                if (lLastTradeYear == -1)
                {
                    lLastTradeYear = CompanyBtcFileTraded.TradeYear;
                }

                if (lLastTradeYear > CompanyBtcFileTraded.TradeYear)
                {
                    lLastTradeYear = CompanyBtcFileTraded.TradeYear;
                }
                lTotalTradeQuantity += CompanyBtcFileTraded.Quantity;

                BOC.Entities.CompanyBtcFileTraded lCompanyBtcFileTraded = new BOC.Entities.CompanyBtcFileTraded();

                lCompanyBtcFileTraded.IsCertificate = CompanyBtcFileTraded.IsCertificate;

                lCompanyAndBtcFile.CompanyBtcFileTradedList.Add(lCompanyBtcFileTraded);
            }

            lCompanyAndBtcFile.LastTradeYear = lLastTradeYear;
            lCompanyAndBtcFile.TotalTradeQuantity = lTotalTradeQuantity;
            lCompanyAndBtcFile.IsTrueBtcFile = false;

            return lCompanyAndBtcFile;
        }
コード例 #2
0
        public IHttpActionResult RegisterUser(RegisterAccount aRegisterAccount)
        {
            try
            {
                BOC.Entities.User lUser = new BOC.Entities.User();
                lUser.UserID = aRegisterAccount.username;
                lUser.UserName = aRegisterAccount.username;
                BOCPasswordHasher lBOCPasswordHasher = new BOCPasswordHasher();
                lUser.Password = lBOCPasswordHasher.HashPassword(aRegisterAccount.password);

                BOC.Entities.Company lCompany = new BOC.Entities.Company();
                lCompany.LoginUserName = aRegisterAccount.username;
                lCompany.CompanyName = aRegisterAccount.companyname;
                lCompany.CompanyLocalName = aRegisterAccount.companylocalname;
                lCompany.CompanyEmail = aRegisterAccount.companyemail;
                lCompany.CompanyType = aRegisterAccount.companytype;
                lCompany.CompanyRegTime = DateTime.Now.ToUniversalTime();
                lCompany.CompanyPhoneNumber = aRegisterAccount.companyphone;
                lCompany.CompanyFaxNumber = aRegisterAccount.companyfax;
                lCompany.CompanyWebSite = aRegisterAccount.companywebsite;
                lCompany.CompanyCountry = aRegisterAccount.companycountry;
                lCompany.CompanyProvince = aRegisterAccount.companyprovince;
                lCompany.CompanyAddress = aRegisterAccount.companyaddress;
                lCompany.RegesterIpAddress = GetIP();

                lCompany.ContactPersons = new List<BOC.Entities.ContactPerson>();

                BOC.Entities.ContactPerson lContactPerson = new BOC.Entities.ContactPerson();
                lContactPerson.ContactPersonName = aRegisterAccount.contactpersonname;
                lContactPerson.ContactPersonEnglishName = aRegisterAccount.contactpersonenglishname;
                lContactPerson.ContactPersonSex = aRegisterAccount.sex;
                lContactPerson.ContactPersonCellPhoneNumber = aRegisterAccount.cellphone;
                lCompany.ContactPersons.Add(lContactPerson);

                BOC.Entities.Role lNewUserRole = _BOCWebDBContext.Roles.Where(e => e.RoleId == "5").First();

                lUser.Roles = new List<BOC.Entities.Role>();
                lUser.Roles.Add(lNewUserRole);

                _BOCWebDBContext.Users.Add(lUser);
                _BOCWebDBContext.Companys.Add(lCompany);

                BOC.Entities.Log lLogCompany = new BOC.Entities.Log();
                lLogCompany.LogTime = DateTime.Now;
                lLogCompany.LogInfo = "[ADD] Company " + lCompany.Dump();
                _BOCWebDBContext.Logs.Add(lLogCompany);

                BOC.Entities.Log lLogUser = new BOC.Entities.Log();
                lLogUser.LogTime = DateTime.Now;
                lLogUser.LogInfo = "[ADD] User " + lUser.Dump();
                _BOCWebDBContext.Logs.Add(lLogUser);

                _BOCWebDBContext.SaveChanges();

                return Ok();
            }
            catch(Exception e)
            {
                return BadRequest("_cannotaddaccount");
            }
        }