Exemple #1
0
        public List <Bud> GetBud()
        {
            List <Bud> bids = new List <Bud>();

            try
            {
                conn.Open();
                SqlCommand cmd = new SqlCommand("GetBud", conn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add(new SqlParameter("@CVRNummer", null));

                SqlDataReader rdr = cmd.ExecuteReader();

                while (rdr.Read())
                {
                    Firms.Add(new Firma(rdr["CVRNummer"].ToString(), rdr["AndetFirma"].ToString(), rdr["Navn"].ToString()));
                }
                rdr.Close();
            }
            catch (SqlException e)
            {
            }
            finally
            {
                conn.Close();
                conn.Dispose();
            }

            return(Firms);
        }
 public ActionResult Edit([Bind(Include = "Id,Name,PhoneNumber,Email,Address,VendorName,VendorEmail,VendorNumber,Description")] Firms firms)
 {
     if (ModelState.IsValid)
     {
         db.Entry(firms).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(firms));
 }
        public ActionResult Create([Bind(Include = "Id,Name,PhoneNumber,Email,Address,VendorName,VendorEmail,VendorNumber,Description")] Firms firms)
        {
            if (ModelState.IsValid)
            {
                db.Firms.Add(firms);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(firms));
        }
Exemple #4
0
        public async Task <IActionResult> PostFirms([FromBody] Firms firms)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.Firms.Add(firms);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetFirms", new { id = firms.FirmID }, firms));
        }
        // GET: Firms/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Firms firms = db.Firms.Find(id);

            if (firms == null)
            {
                return(HttpNotFound());
            }
            return(View(firms));
        }
Exemple #6
0
        public ActionResult Edit(int id, Firms firm)
        {
            try {
                using (DB_DocumentsEntities dbModel = new DB_DocumentsEntities())
                {
                    dbModel.Entry(firm).State = EntityState.Modified;
                    dbModel.SaveChanges();
                }

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }// Edit
        public ActionResult DeleteConfirmed(int id)
        {
            Firms firms = db.Firms.Find(id);

            db.Firms.Remove(firms);
            try
            {
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                if (ex.Message == "An error occurred while updating the entries. See the inner exception for details.")
                {
                    ViewBag.Error = "Silmek istediğiniz firmaya kayıtlı ürün/ürünler bulunmaktadır. Silme işlemi gerçekleştirilemedi. Lütfen ürün/ürünler üzerinde firma değişikliği yapınız.";
                    return(View("Delete", firms));
                }
            }
            return(RedirectToAction("Index"));
        }
Exemple #8
0
        public async Task <List <Survey> > getSurveys([FromRoute] Guid firmID)
        {
            List <Survey> surveys = new List <Survey>();
            Firms         firm    = await _context.Firms.SingleOrDefaultAsync(x => x.FirmID == firmID);

            if (firm == null)
            {
                return(null);
            }
            List <CompanyProfiles> companyProfiles = new List <CompanyProfiles>();

            companyProfiles = _context.CompanyProfiles.Where(x => x.FirmID == firmID).ToList();

            foreach (var companyProfile in companyProfiles)
            {
                var survey = await getSurvey(companyProfile, companyProfile.CompanyProfileID);

                survey.Firm = firm;
                surveys.Add(survey);
            }

            return(surveys);
        }
Exemple #9
0
        public string Create(string s1, string s2)
        {
            try
            {
                byte t1 = byte.Parse(Request["AddressType1"]);

                Addresses addresses1 = new Addresses()
                {
                    Country      = Request["Country1"],
                    City         = Request["City1"],
                    Street       = Request["Street1"],
                    HouseNumber  = Request["HouseNumber1"],
                    OfficeNumber = int.Parse(Request["OfficeNumber1"]),
                    addressTypes = dbModel.addressTypes.First(t => t.addressTypeId == t1)
                };

                byte t2 = byte.Parse(Request["AddressType2"]);

                Addresses addresses2 = new Addresses()
                {
                    Country      = Request["Country2"],
                    City         = Request["City2"],
                    Street       = Request["Street2"],
                    HouseNumber  = Request["HouseNumber2"],
                    OfficeNumber = int.Parse(Request["OfficeNumber2"]),
                    addressTypes = dbModel.addressTypes.First(t => t.addressTypeId == t2)
                };

                Directors director = new Directors()
                {
                    Surname    = Request["Surname"],
                    Name       = Request["Name"],
                    SecondName = Request["SecondName"]
                };



                var result1 = dbModel.Addresses.Add(addresses1);
                var result2 = dbModel.Addresses.Add(addresses2);
                var result3 = dbModel.Directors.Add(director);


                dbModel.SaveChanges();


                var Id1 = result1.IdAddress;
                var Id2 = result2.IdAddress;
                var Id3 = result3.IdDirector;


                Firms f = new Firms()
                {
                    TitleFirm = Request["FirmTitle"],

                    IdAddressActual = Id1,

                    IdAddressLegal = Id2,

                    IdDirector = Id3
                };

                dbModel.Firms.Add(f);

                dbModel.SaveChanges();

                var r = new { status = 200 };

                return(JsonConvert.SerializeObject(r));

                //return JsonConvert.SerializeObject("{status: '200'}");
            }
            catch (Exception ex)
            {
                var r = new { status = 500 };

                return(JsonConvert.SerializeObject(r));

                /*501 Not Implemented («не реализовано»);
                 * 500 Internal Server Error («внутренняя ошибка сервера»)
                 */
            }
        }// string Create(Firms firm)
Exemple #10
0
        public string CreateProvider(string s1, string s2)
        {
            try
            {
                byte t1 = byte.Parse(Request["AddressType1"]);

                Addresses addresses1 = new Addresses()
                {
                    Country      = Request["Country1"],
                    City         = Request["City1"],
                    Street       = Request["Street1"],
                    HouseNumber  = Request["HouseNumber1"],
                    OfficeNumber = int.Parse(Request["OfficeNumber1"]),
                    addressTypes = dbModel.addressTypes.First(t => t.addressTypeId == t1)
                };

                byte t2 = byte.Parse(Request["AddressType2"]);

                Addresses addresses2 = new Addresses()
                {
                    Country      = Request["Country2"],
                    City         = Request["City2"],
                    Street       = Request["Street2"],
                    HouseNumber  = Request["HouseNumber2"],
                    OfficeNumber = int.Parse(Request["OfficeNumber2"]),
                    addressTypes = dbModel.addressTypes.First(t => t.addressTypeId == t2)
                };


                byte t3 = byte.Parse(Request["AddressType3"]);

                Addresses addresses3 = new Addresses()
                {
                    Country      = Request["Country3"],
                    City         = Request["City3"],
                    Street       = Request["Street3"],
                    HouseNumber  = Request["HouseNumber3"],
                    OfficeNumber = int.Parse(Request["OfficeNumber3"]),
                    addressTypes = dbModel.addressTypes.First(t => t.addressTypeId == t3)
                };


                Directors director = new Directors()
                {
                    Surname    = Request["Surname"],
                    Name       = Request["Name"],
                    SecondName = Request["SecondName"]
                };


                var result1 = dbModel.Addresses.Add(addresses1);
                var result2 = dbModel.Addresses.Add(addresses2);
                var result3 = dbModel.Directors.Add(director);
                var result4 = dbModel.Addresses.Add(addresses3);


                dbModel.SaveChanges();


                var Id1 = result1.IdAddress;
                var Id2 = result2.IdAddress;
                var Id3 = result3.IdDirector;
                var Id4 = result4.IdAddress;

                Providers pr = new Providers()
                {
                    TitleProvider = Request["FirmTitle"],

                    IdAddressProviderActual = Id1,

                    IdAddressProviderLegal = Id2,

                    IdDirector = Id3,

                    IdAddressStore = Id4
                };


                int firmID = int.Parse(Request["firm"]);

                Firms firm = dbModel.Firms.FirstOrDefault(f => f.IdFirm == firmID);

                pr.Firms.Add(firm);

                dbModel.Providers.Add(pr);
                dbModel.SaveChanges();


                var r = new { status = 200 };

                return(JsonConvert.SerializeObject(r));

                //return JsonConvert.SerializeObject("{status: '200'}");
            }
            catch (Exception ex)
            {
                var r = new { status = 500 };

                return(JsonConvert.SerializeObject(r));

                /*501 Not Implemented («не реализовано»);
                 * 500 Internal Server Error («внутренняя ошибка сервера»)
                 */
            }
        }//CreateProvider