コード例 #1
0
        public IHttpActionResult PostOwner(CITY data)
        {
            INF370Entities db = new INF370Entities();

            db.Configuration.ProxyCreationEnabled = false;

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            try
            {
                db.CITies.Add(data);
                db.SaveChanges();
            }
            catch (Exception)
            {
                dynamic User = new ExpandoObject();
                User.Message = "Something went wrong !";
                return(User);
            }



            return(Ok(data));
        }
コード例 #2
0
ファイル: RegionDal.cs プロジェクト: blissvisitor/QRApp
        /// <summary>
        /// 根据省份id获取城市
        /// </summary>
        /// <param name="proId">province_id</param>
        /// <returns></returns>
        public static List <CITY> getCityByProId(string proId)
        {
            List <CITY> lst = new List <CITY>();

            try
            {
                string    sql = "select id,province_id,city_id,city_name from city  where  province_id='" + proId + "' order by city_id ";
                DataTable dt  = MySqlDHelper.ExecuteDataTable(sql);
                if (dt.Rows.Count > 0)
                {
                    foreach (DataRow row in dt.Rows)
                    {
                        CITY city = new CITY();
                        city.ID          = int.Parse(row["id"].ToString());
                        city.PROVINCE_ID = row["province_id"].ToString();
                        city.CITY_ID     = row["city_id"].ToString();
                        city.CITY_NAME   = row["city_name"].ToString();
                        lst.Add(city);
                    }
                }
                return(lst);
            }
            catch (Exception e)
            {
                string err = new DateTime().ToString() + " 根据省份id获取城市:region/getCityByProId ,错误:" + e.Message;
                LogHelper.WriteLog(err);
                return(lst);
            }
        }
コード例 #3
0
ファイル: CityController.cs プロジェクト: s0w0s/ttip
 public ActionResult DeleteConfirmed(string id)
 {
     CITY cITY = db.CITY.Find(id);
     db.CITY.Remove(cITY);
     db.SaveChanges();
     return RedirectToAction("Index");
 }
コード例 #4
0
        public IHttpActionResult PutOwnerMaster(CITY City)
        {
            db.Configuration.ProxyCreationEnabled = false;
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                CITY objEmp = new CITY();
                objEmp = db.CITies.Find(City.CITYID);
                if (objEmp != null)
                {
                    objEmp.CITYNAME   = City.CITYNAME;
                    objEmp.PROVINCEID = City.PROVINCEID;
                }
                int i = this.db.SaveChanges();
            }
            catch (Exception)
            {
                dynamic User = new ExpandoObject();
                User.Message = "Something went wrong !";
                return(User);
            }
            return(Ok(City));
        }
コード例 #5
0
        public IEnumerable <CITY> GetCity(string city_name)
        {
            List <CITY>   myList     = new List <CITY>();
            SqlConnection connection = new SqlConnection(this.connectionStrings.MyDefaultConnection);

            //connection.Open();
            if (string.IsNullOrWhiteSpace(city_name))
            {
                city_name = "%%";
            }
            else
            {
                city_name = "%" + city_name + "%";
            }
            SqlDataAdapter da = new SqlDataAdapter("select city_num,city_name from main.cr_city where city_name_a like @city_name", connection);

            da.SelectCommand.Parameters.Add(new SqlParameter("@city_name", city_name));
            DataSet ds = new DataSet();

            da.Fill(ds);
            if (ds.Tables.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    CITY CITY = new CITY();
                    CITY.city_num  = int.Parse(ds.Tables[0].Rows[i]["city_num"].ToString());
                    CITY.city_name = ds.Tables[0].Rows[i]["city_name"].ToString();
                    myList.Add(CITY);
                }
            }
            return(myList);
        }
コード例 #6
0
 public void DeleteCity(CityModel City)
 {
     if (City == null)
     {
         throw new ArgumentNullException();
     }
     using (AppTourEntities data = new AppTourEntities())
     {
         CITY current = data.CITY.Where(x => x.ID == City.Id).SingleOrDefault();
         if (current != null)
         {
             try
             {
                 data.DeleteObject(current);
                 data.SaveChanges();
             }
             catch (UpdateException upx)
             {
                 throw new UpdateException(upx.InnerException.Message);
             }
             catch (Exception e)
             {
                 if (e.InnerException != null)
                 {
                     throw new Exception(e.InnerException.Message);
                 }
                 throw;
             }
         }
     }
 }
コード例 #7
0
        public void UpdateCity(CityModel City)
        {
            using (AppTourEntities data = new AppTourEntities())
            {
                CITY current = data.CITY.Where(x => City.Id == x.ID).SingleOrDefault();
                if (current != null)
                {
                    try
                    {
                        current.COUNTRY = data.COUNTRY.Where(x => x.ID == City.Country.Id).SingleOrDefault();
                        current.NAME    = City.Name;

                        data.SaveChanges();
                    }
                    catch (Exception e)
                    {
                        if (e.InnerException != null)
                        {
                            throw new Exception(e.InnerException.Message);
                        }
                        throw;
                    }
                }
            }
        }
コード例 #8
0
        public IHttpActionResult PutOwnerMaster(CITY City)
        {
            db.Configuration.ProxyCreationEnabled = false;
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                CITY objEmp = new CITY();
                objEmp = db.CITies.Find(City.CITYID);
                if (objEmp != null)
                {
                    objEmp.CITYNAME   = City.CITYNAME;
                    objEmp.PROVINCEID = City.PROVINCEID;
                }
                int i = this.db.SaveChanges();
            }
            catch (Exception)
            {
                return(null);
            }
            return(Ok(City));
        }
コード例 #9
0
        // PUT: odata/CITies(5)
        public IHttpActionResult Put([FromODataUri] decimal key, CITY cITY)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (key != cITY.ID)
            {
                return(BadRequest());
            }

            db.Entry(cITY).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CITYExists(key))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(Updated(cITY));
        }
コード例 #10
0
        public bool DeleteOwner(int id)
        {
            INF370Entities db = new INF370Entities();

            db.Configuration.ProxyCreationEnabled = false;

            try
            {
                CITY CityDetails = db.CITies.Find(id);
                if (CityDetails == null)
                {
                    return(false);
                }
                else
                {
                    var propExist = db.AREAs.Where(kk => kk.CITYID == CityDetails.CITYID).ToList();
                    if (propExist.Count == 0)
                    {
                        db.CITies.Remove(CityDetails);
                        db.SaveChanges();
                    }
                    else
                    {
                        return(false);
                    }
                }

                return(false);
            }
            catch (Exception)
            {
                return(false);
            }
        }
コード例 #11
0
        public async Task <IHttpActionResult> PostCITY(CITY cITY)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.CITY.Add(cITY);

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (CITYExists(cITY.CityCode))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = cITY.CityCode }, cITY));
        }
コード例 #12
0
        public async Task <IHttpActionResult> PutCITY(string id, CITY cITY)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != cITY.CityCode)
            {
                return(BadRequest());
            }

            db.Entry(cITY).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CITYExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #13
0
        public IHttpActionResult Patch([FromODataUri] decimal key, Delta <CITY> patch)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            CITY cITY = db.CITies.Find(key);

            if (cITY == null)
            {
                return(NotFound());
            }

            patch.Patch(cITY);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CITYExists(key))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(Updated(cITY));
        }
コード例 #14
0
 public Address(string street, int houseNO, CITY city, int zipcode)
 {
     Street  = street;
     HouseNO = houseNO;
     City    = city;
     ZipCode = zipcode;
 }
コード例 #15
0
 /// <summary>
 /// Initializes a new instance of the Branch class to the value indicated
 /// by the given parameters.
 /// </summary>
 public Client(string name, string street, int houseNo, CITY city, int zipCode, string phoneNumber = null)
 {
     BirthDate   = new DateTime(1996, 1, 1);
     Name        = name;
     Add         = new Address(street, houseNo, city, zipCode);
     Location    = Add;
     PhoneNumber = phoneNumber;
 }
コード例 #16
0
ファイル: CityController.cs プロジェクト: s0w0s/ttip
 public ActionResult Edit([Bind(Include = "CITY_NAME")] CITY cITY)
 {
     if (ModelState.IsValid)
     {
         db.Entry(cITY).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(cITY);
 }
コード例 #17
0
        public ActionResult CityIndex(string id)
        {
            CITY s = new CITY();

            ViewBag.Title = "City List";
            List <SelectList> list = new List <SelectList>();

            ViewBag.country_id = new SelectList(countryUtil.GetCountry(), "Value", "Text");
            ViewBag.state_id   = list;
            return(View(s));
        }
コード例 #18
0
ファイル: CityController.cs プロジェクト: s0w0s/ttip
        public ActionResult Create([Bind(Include = "CITY_NAME")] CITY cITY)
        {
            if (ModelState.IsValid)
            {
                db.CITY.Add(cITY);
                db.SaveChanges();
                return Redirect("~/Place");
            }

            return View(cITY);
        }
コード例 #19
0
        // POST: odata/CITies
        public IHttpActionResult Post(CITY cITY)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.CITies.Add(cITY);
            db.SaveChanges();

            return(Created(cITY));
        }
コード例 #20
0
ファイル: Branch.cs プロジェクト: 1danmi/dotNet-Project
 /// <summary>
 ///      Initializes a new instance of the Branch class to the value indicated
 ///      by the given parameters.
 /// </summary>
 public Branch(string name, string street, int houseNo, CITY city, int zipCode, string managerName, string phoneNumber, KOSHER kosher)
 {
     Add         = new Address();
     Name        = name;
     Add.Street  = street;
     Add.HouseNO = houseNo;
     Add.City    = city;
     Add.ZipCode = zipCode;
     ManagerName = managerName;
     PhoneNumber = phoneNumber;
     Kosher      = kosher;
 }
コード例 #21
0
        public bool PutCity(CITY city)
        {
            var isUpdated = sportsSideService.PutCity(city);

            if (isUpdated)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #22
0
ファイル: CityController.cs プロジェクト: s0w0s/ttip
 // GET: City/Delete/5
 public ActionResult Delete(string id)
 {
     if (id == null)
     {
         return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
     }
     CITY cITY = db.CITY.Find(id);
     if (cITY == null)
     {
         return HttpNotFound();
     }
     return View(cITY);
 }
コード例 #23
0
        public bool PostCity(CITY city)
        {
            var isSaved = sportsSideService.PostCity(city);

            if (isSaved)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #24
0
        public bool DeleteCity(CITY city)
        {
            var isDeleted = sportsSideService.DeleteCity(city);

            if (isDeleted)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #25
0
 public bool DeleteCity(CITY city)
 {
     try
     {
         db.Entry(city).State = System.Data.Entity.EntityState.Deleted;
         db.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
コード例 #26
0
 public bool PostCity(CITY city)
 {
     try
     {
         db.CITY.Add(city);
         db.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
コード例 #27
0
        public async Task <IHttpActionResult> DeleteCITY(string id)
        {
            CITY cITY = await db.CITY.FindAsync(id);

            if (cITY == null)
            {
                return(NotFound());
            }

            db.CITY.Remove(cITY);
            await db.SaveChangesAsync();

            return(Ok(cITY));
        }
コード例 #28
0
        // DELETE: odata/CITies(5)
        public IHttpActionResult Delete([FromODataUri] decimal key)
        {
            CITY cITY = db.CITies.Find(key);

            if (cITY == null)
            {
                return(NotFound());
            }

            db.CITies.Remove(cITY);
            db.SaveChanges();

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #29
0
        public IHttpActionResult DeleteOwner(int id)
        {
            INF370Entities db = new INF370Entities();

            db.Configuration.ProxyCreationEnabled = false;


            CITY CityDetails = db.CITies.Find(id);

            if (CityDetails == null)
            {
                return(NotFound());
            }

            db.CITies.Remove(CityDetails);
            db.SaveChanges();

            return(Ok(CityDetails));
        }
コード例 #30
0
        public double revenueForCity(CITY city)
        {
            var x = from a in dal.getOrdersList()
                    group a by dal.getBranch(a.BranchID).Add.City into g
                    select g;

            double sum = 0;

            foreach (var item in x)
            {
                if (item.Key == city)
                {
                    foreach (var i in item)
                    {
                        sum += calcTotalPrice(i.OrderID);
                    }
                }
            }
            return(sum);
        }