Пример #1
0
        private static void Main(string[] args)
        {
            DataAccessManagerDataContext dbContext     = new DataAccessManagerDataContext();
            const string          fileName             = @"C:\Users\spadmin\documents\visual studio 2012\Projects\MoeSto\XMLParser\XML\XMLFile.xml";
            XDocument             xDoc                 = XDocument.Load(fileName);
            var                   companies            = xDoc.Root;
            List <Companies>      listOfCompanies      = new List <Companies>();
            List <CompanyDetails> listOfCompanyDetails = new List <CompanyDetails>();

            foreach (var company in companies.Elements("Company"))
            {
                var dbCompany        = new Companies();
                var dbCompanyDetails = new CompanyDetails();

                dbCompanyDetails.Name                  = GetElementValue(company.Element("Name"));
                dbCompanyDetails.Unp                   = GetInt(company.Element("Unp"));
                dbCompanyDetails.Address               = GetElementValue(company.Element("Address"));
                dbCompanyDetails.Email                 = GetElementValue(company.Element("Email"));
                dbCompanyDetails.Phones                = GetElementValue(company.Element("Phones"));
                dbCompanyDetails.CatalogUrl            = company.Element("CatalogUrl").Value;
                dbCompanyDetails.FoundOnCardone        = GetBool(company.Element("FoundOnCardone"));
                dbCompanyDetails.CardoneStatus         = company.Element("CardoneStatus").Value;
                dbCompanyDetails.CardoneContractNo     = GetInt(company.Element("CardoneContractNo"));
                dbCompanyDetails.CardoneContractStatus = company.Element("CardoneContractStatus").Value;
                GetCoordinates(company.Element("Coordinates"), dbCompanyDetails);

                //GetCoordinates(company.Element("Coordinates"), dbCompany );

                listOfCompanyDetails.Add(dbCompanyDetails);
                //listOfCompanies.Add(dbCompany);
            }
            dbContext.Companies.InsertAllOnSubmit(listOfCompanies);
            dbContext.CompanyDetails.InsertAllOnSubmit(listOfCompanyDetails);
            dbContext.SubmitChanges();
        }
Пример #2
0
        public ActionResult UploadImgs()
        {
            if (Request.Files.Count > 0)
            {
                var file = Request.Files[0];

                if (file != null && file.ContentLength > 0)
                {
                    dbContext.Images.InsertOnSubmit(Utils.GetImgFromRequst(Request, file));
                    dbContext.SubmitChanges();
                }
            }
            //in json result pass needed information for description of image
            return(Json(new { text = "boom!" }, JsonRequestBehavior.AllowGet));
        }