コード例 #1
0
        public IHttpActionResult GettblCity(int id)
        {
            //tblCity tblCity = db.tblCities.Find(id);
            //if (tblCity == null)
            //{
            //    return NotFound();
            //}
            //return Ok(tblCity);

            var data = db.tblCities.Where(w => w.ID == id).FirstOrDefault();

            if (data == null)
            {
                return(Ok(new { code = 1, data = "Not found" }));
            }
            else
            {
                tblCity model = new tblCity();
                model.ID        = data.ID;
                model.Name      = data.Name;
                model.StateID   = data.StateID;
                model.Created   = System.DateTime.Now;
                model.CreatedBy = data.CreatedBy;
                model.Updated   = System.DateTime.Now;
                model.UpdatedBy = data.UpdatedBy;
                model.Active    = Convert.ToBoolean(data.Active);

                return(Ok(new { code = 0, data = model }));
            }
        }
コード例 #2
0
        public IHttpActionResult PuttblCity(int id, tblCity tblCity)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != tblCity.Id)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #3
0
 private bool SaveData()
 {
     objCommon = new clsCommon();
     if (objCommon.IsRecordExists("tblCity", tblCity.ColumnNames.AppCity, tblCity.ColumnNames.AppCityID, txtCity.Text, hdnPKID.Value))
     {
         DInfo.ShowMessage("City already exits.", Enums.MessageType.Error);
         return(false);
     }
     objCommon = null;
     objCity   = new tblCity();
     if (!string.IsNullOrEmpty(hdnPKID.Value) && hdnPKID.Value != "")
     {
         objCity.LoadByPrimaryKey(Convert.ToInt32(hdnPKID.Value));
     }
     else
     {
         objCity.AddNew();
     }
     objCity.AppCity      = txtCity.Text;
     objCity.s_AppStateID = ddlState.SelectedValue.ToString();
     objCity.Save();
     iCityID = objCity.AppStateID;
     objCity = null;
     return(true);
 }
コード例 #4
0
    private bool Delete(int intPKID)
    {
        bool retval = false;

        objState = new tblState();
        tblCity objCity = new tblCity();

        if (objState.LoadByPrimaryKey(intPKID))
        {
            objCity.Where.AppStateID.Value = intPKID;
            objCity.Query.Load();
            if (objCity.RowCount > 0)
            {
                retval = false;
            }
            else
            {
                objState.MarkAsDeleted();
                objState.Save();
                retval = true;
            }
        }
        objCity  = null;
        objState = null;
        return(retval);
    }
コード例 #5
0
 private void SetValuesToControls()
 {
     if (!string.IsNullOrEmpty(hdnPKID.Value) && hdnPKID.Value != "")
     {
         objPinCode = new tblPinCode();
         if (objPinCode.LoadByPrimaryKey(Convert.ToInt32(hdnPKID.Value)))
         {
             txtPINCode.Text     = objPinCode.AppPinCode.ToString();
             chkIsActive.Checked = objPinCode.AppIsActive;
             tblCity objCity = new tblCity();
             if (objCity.LoadByPrimaryKey(objPinCode.AppCityID))
             {
                 objCommon = new clsCommon();
                 tblState objState = new tblState();
                 if (objState.LoadByPrimaryKey(objCity.AppStateID))
                 {
                     ddlCountry.SelectedValue = objState.s_AppCountryID;
                     objCommon.FillDropDownList(ddlState, "tblState", tblState.ColumnNames.AppState, tblState.ColumnNames.AppStateID, "-- Select State --", tblState.ColumnNames.AppCountryID + "=" + ddlCountry.SelectedValue);
                     ddlState.SelectedValue = objState.s_AppStateID;
                     objCommon.FillDropDownList(ddlCity, "tblCity", tblCity.ColumnNames.AppCity, tblCity.ColumnNames.AppCityID, "-- Select City --", tblCity.ColumnNames.AppStateID + "=" + ddlState.SelectedValue);
                     ddlCity.SelectedValue = objCity.s_AppCityID;
                 }
                 objState  = null;
                 objCommon = null;
             }
             objCity = null;
         }
         objPinCode = null;
     }
 }
コード例 #6
0
ファイル: CitysController.cs プロジェクト: AhsanAshfaq/JTR
        // GET: /Users/
        public ActionResult Index(int isdelete = 0, int restoreid = 0)
        {
            var list = (dynamic)null;

            TempData["restore"] = "";
            if (isdelete == 0)
            {
                if (restoreid > 0)
                {
                    if (db.tblCity.Any(a => a.CityID == restoreid && a.IsDelete == true))
                    {
                        tblCity tblCity = db.tblCity.Find(restoreid);
                        tblCity.IsDelete        = false;
                        db.Entry(tblCity).State = EntityState.Modified;
                        db.SaveChanges();
                        TempData["msg"] = "Record Restore Successfully";
                        // return View("Index","City");
                    }
                }
                list = db.tblCity.Where(a => a.IsDelete != true).OrderByDescending(a => a.CityID).ToList();
            }
            else
            {
                TempData["restore"] = "restore";
                list = db.tblCity.Where(a => a.IsDelete == true).OrderByDescending(a => a.CityID).ToList();
            }
            return(View(list));
        }
コード例 #7
0
        public ActionResult AddCity(string jsonData)
        {
            SPResponse result      = new SPResponse();
            var        userDetails = (CustomerLoginDetail)Session["UserSession"];
            string     CityId      = "";

            try
            {
                JavaScriptSerializer json_serializer = new JavaScriptSerializer();
                json_serializer.MaxJsonLength = int.MaxValue;
                object[] objData = (object[])json_serializer.DeserializeObject(jsonData);
                tblCity  objcity = new tblCity();
                foreach (Dictionary <string, object> item in objData)
                {
                    objcity.CityName    = Convert.ToString(item["cityNm"]);
                    objcity.CreatedBy   = userDetails.LoginId;
                    objcity.CreatedDate = DateTime.Now;
                    CityId           = Convert.ToString(item["CityId"]);
                    objcity.IsActive = Convert.ToBoolean(item["IsActive"]);
                    if (CityId != "")
                    {
                        objcity.CityId = Convert.ToInt32(CityId);
                    }
                    else
                    {
                    }
                }
                result = COR.AddCity(objcity);
            }
            catch (Exception ex)
            {
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
コード例 #8
0
    void cmbRegion_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)
    {
        try
        {
            cmbCity.Items.Clear();
            cmbCity.Items.Add(new RadComboBoxItem("[Select City]", "-1"));
            cmbCity.AppendDataBoundItems = true;
            cmbCity.DataSource           = GoProGo.Business.Lookup.Geo.GetCitiesByRegionID(int.Parse(cmbRegion.SelectedItem.Value));
            cmbCity.DataTextField        = "City";
            cmbCity.DataValueField       = "ID";
            cmbCity.DataBind();

            if (!IsPostBack)
            {
                tblCity city = GoProGoDC.GeoDC.GetCityByRegionAndCity(int.Parse(cmbRegion.SelectedItem.Value), UserBrowsingInfo.City).SingleOrDefault <tblCity>();
                if (city != null)
                {
                    cmbCity.SelectedValue = city.ID.ToString();
                }
                else
                {
                    cmbCategory.SelectedIndex = 0;
                }
                //TODO: Log this situation
                //throw new Exception("City can not be null.");
            }
        }
        catch (Exception ex)
        {
            ThrowError(this, new ControlErrorArgs()
            {
                InnerException = ex, Message = ex.Message, Severity = 1
            });
        }
    }
コード例 #9
0
        public SPResponse ActiveInactiveCity(int CityId)
        {
            tblCity    objcity = new tblCity();
            SPResponse result  = new SPResponse();

            using (var context = new CommonDBContext())
            {
                objcity = context.tblCities.Where(x => x.CityId == CityId).FirstOrDefault();

                if (objcity.IsActive == true)
                {
                    objcity.IsActive = false;
                }
                else
                {
                    objcity.IsActive = true;
                }

                context.tblCities.AddOrUpdate(objcity);
                context.SaveChanges();
                result.ResponseCode    = "00";
                result.ResponseMessage = "City Updated Successfully";
            }
            return(result);
        }
コード例 #10
0
 public int Save(tblCity tbl)
 {
     tbl.IsDelete = false;
     objData.tblCities.Add(tbl);
     objData.SaveChanges();
     return(tbl.CityId.Value);
 }
コード例 #11
0
        public async Task <IActionResult> Edit(int id, [Bind("city_Id,state_Id,City")] tblCity tblCity)
        {
            if (id != tblCity.city_Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(tblCity);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!tblCityExists(tblCity.city_Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["state_Id"] = new SelectList(_context.tblState, "state_Id", "State", tblCity.state_Id);
            return(View(tblCity));
        }
コード例 #12
0
ファイル: CityController.cs プロジェクト: Belal-95/repos
        /// <summary>
        /// Action Methods To Be Used By JQuery Ajax
        /// </summary>


        public ActionResult GetCityList()
        {
            if (Session["AdminUser"] == null)
            {
                return(RedirectToAction("Login", "Home"));
            }

            List <tblCity> cityList = new List <tblCity>();

            foreach (tblCity city in db.tblCities.Include(c => c.tblState.tblCountry).ToList())
            {
                tblCity objCity = new tblCity();
                objCity.CityId     = city.CityId;
                objCity.CityName   = city.CityName;
                objCity.IsActive   = city.IsActive;
                objCity.CountryId  = city.CountryId;
                objCity.StateId    = city.StateId;
                objCity.tblCountry = new tblCountry()
                {
                    CountryId = city.CountryId, CountryName = city.tblCountry.CountryName
                };
                objCity.tblState = new tblState()
                {
                    StateId = city.StateId, StateName = city.tblState.StateName
                };

                cityList.Add(objCity);
            }
            return(Json(cityList, JsonRequestBehavior.AllowGet));
        }
コード例 #13
0
        public string ChangeStatus(long id)
        {
            tblCity user = _dbRepository.SelectById(id);

            user.IsActive = !user.IsActive;
            return(_dbRepository.Update(user));
        }
コード例 #14
0
ファイル: City.aspx.cs プロジェクト: KrunalPatel2194/FabyMart
    private bool Delete(int intPKID)
    {
        bool retval = false;

        objCity = new tblCity();
        tblPinCode objPINCode = new tblPinCode();

        if (objCity.LoadByPrimaryKey(intPKID))
        {
            objPINCode.Where.AppCityID.Value = intPKID;
            objPINCode.Query.Load();
            if (objPINCode.RowCount > 0)
            {
                retval = false;
            }
            else
            {
                objCity.MarkAsDeleted();
                objCity.Save();
                retval = true;
            }
        }
        objPINCode = null;
        objCity    = null;
        return(retval);
    }
コード例 #15
0
        public bool InsertCity(CityModel cityModel)
        {
            try
            {
                tblCity entity = new tblCity();
                entity = _unitOfWork.CityRepository.Get(filter: prop => prop.CityName.Equals(cityModel.CityName)).FirstOrDefault();
                Guid newGuid = Guid.NewGuid();
                if (entity == null)
                {
                    tblCity city = new tblCity()
                    {
                        CityID   = newGuid,
                        CityName = cityModel.CityName,
                        StateID  = cityModel.StateID
                    };
                    _unitOfWork.CityRepository.Insert(city);
                    _unitOfWork.Save();
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception e)
            {
                string currentFile = new System.Diagnostics.StackTrace(true).GetFrame(0).GetFileName();
                ErrorLogger.LogException(e, currentFile);

                return(false);
            }
        }
コード例 #16
0
        public ActionResult DeleteConfirmed(int id)
        {
            tblCity tblCity = db.tblCities.Find(id);

            db.tblCities.Remove(tblCity);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #17
0
        public bool DeleteCityLogic(Guid cityGuid)
        {
            tblCity city = bringlyEntities.tblCities.Where(c => c.CityGuid == cityGuid).FirstOrDefault();

            city.IsDeleted = true;
            bringlyEntities.SaveChanges();
            return(true);
        }
コード例 #18
0
ファイル: CityController.cs プロジェクト: saira332/JQuery_MVC
        public ActionResult UpdateCity(tblCity c)
        {
            tblCity result = db.tblCities.Single(city => city.CityId == c.CityId);

            result.CityName = c.CityName;
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #19
0
ファイル: CityController.cs プロジェクト: Belal-95/repos
        public int DeleteCityDetails(int cityId)
        {
            tblCity city = db.tblCities.Find(cityId);

            db.tblCities.Remove(city);

            return(db.SaveChanges());
        }
コード例 #20
0
        public IHttpActionResult PuttblCity(tblCity tblCity)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            //if (id != tblCity.ID)
            //{
            //    return BadRequest();
            //}
            //db.Entry(tblCity).State = EntityState.Modified;
            //try
            //{
            //    db.SaveChanges();
            //}
            //catch (DbUpdateConcurrencyException)
            //{
            //    if (!tblCityExists(id))
            //    {
            //        return NotFound();
            //    }
            //    else
            //    {
            //        throw;
            //    }
            //}
            //return StatusCode(HttpStatusCode.NoContent);

            if (tblCity == null)
            {
                throw new ArgumentNullException("tblCity");
            }

            var data = db.tblCities.Where(w => w.ID == tblCity.ID).Count();//.FirstOrDefault();

            if (data >= 0)
            {
                tblCity city = new tblCity();
                city.ID        = tblCity.ID;
                city.StateID   = tblCity.StateID;
                city.Name      = tblCity.Name;
                city.Created   = System.DateTime.Now;
                city.CreatedBy = tblCity.CreatedBy;
                city.Updated   = System.DateTime.Now;
                city.UpdatedBy = tblCity.UpdatedBy;
                city.Active    = Convert.ToBoolean(tblCity.Active);

                db.Entry(city).State = EntityState.Modified;
                db.SaveChanges();

                return(Ok(new { code = 0, data = "City updated successfully." }));
            }
            else
            {
                return(Ok(new { code = 1, data = "City not found." }));
            }
        }
コード例 #21
0
        internal void Update(tblCity model)
        {
            tblCity newobj = objData.tblCities.Where(p => p.CityId == model.CityId && p.IsDelete == false).FirstOrDefault();

            newobj.CityName = model.CityName;
            newobj.StateId  = model.StateId;
            newobj.Pincode  = model.Pincode;
            objData.SaveChanges();
        }
コード例 #22
0
ファイル: CitysController.cs プロジェクト: AhsanAshfaq/JTR
 public ActionResult Create([Bind(Include = "CityID,CityName,CreatedBy,UpdatedBy,CreateDate,UpdateDate,IsLogin,IsDelete,IsActive,CountryID,ProvinceID,DeleteBy,DeleteDate")] tblCity tblCity)
 {
     if (ModelState.IsValid)
     {
         db.tblCity.Add(tblCity);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(tblCity));
 }
コード例 #23
0
        public void Delete()
        {
            using (WorkWithMeDataContext oDC = new WorkWithMeDataContext())
            {
                tblCity city = (from c in oDC.tblCities where c.Id == Id select c).FirstOrDefault();

                oDC.tblCities.DeleteOnSubmit(city);
                oDC.SubmitChanges();
            }
        }
コード例 #24
0
        public tblCity GetCityById(int CityId)
        {
            tblCity objcity = new tblCity();

            using (var context = new CommonDBContext())
            {
                objcity = context.tblCities.Where(x => x.CityId == CityId).FirstOrDefault();
            }
            return(objcity);
        }
コード例 #25
0
 public ActionResult Edit([Bind(Include = "ID,Name")] tblCity tblCity)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tblCity).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(tblCity));
 }
コード例 #26
0
        public SavingResult SaveNewRecord(tblCity SaveModel)
        {
            SavingResult res = new SavingResult();

            //-- Perform Validation
            //res.ExecutionResult = eExecutionResult.ValidationError;
            //res.ValidationError = "Validation error message";
            //return res;

            //--
            using (dbVisionEntities db = new dbVisionEntities())
            {
                //tblCity SaveModel;
                if (SaveModel.CityName == "")
                {
                    res.ValidationError = "Can not accept blank value. Please enter City Name.";
                    res.ExecutionResult = eExecutionResult.ValidationError;
                    return(res);
                }
                else if (IsDuplicateRecord(SaveModel.CityName, SaveModel.CityID, SaveModel.StateID, db))
                {
                    res.ValidationError = "Can not accept duplicate value. The City Name is already exists.";
                    res.ExecutionResult = eExecutionResult.ValidationError;
                    return(res);
                }

                SaveModel.CountryID = db.tblStates.FirstOrDefault(r => r.StateID == SaveModel.StateID).CountryID;
                if (SaveModel.CityID == 0) // New Entry
                {
                    SaveModel.rcuid = Model.CommonProperties.LoginInfo.LoggedinUser.UserID;
                    SaveModel.rcdt  = DateTime.Now;
                    db.tblCities.Add(SaveModel);
                }
                else
                {
                    SaveModel.reuid = Model.CommonProperties.LoginInfo.LoggedinUser.UserID;
                    SaveModel.redt  = DateTime.Now;
                    db.tblCities.Attach(SaveModel);
                    db.Entry(SaveModel).State = System.Data.Entity.EntityState.Modified;
                }

                //--
                try
                {
                    db.SaveChanges();
                    res.PrimeKeyValue   = SaveModel.CityID;
                    res.ExecutionResult = eExecutionResult.CommitedSucessfuly;
                }
                catch (Exception ex)
                {
                    CommonFunctions.GetFinalError(res, ex);
                }
            }
            return(res);
        }
コード例 #27
0
        public ActionResult Create([Bind(Include = "ID,Name")] tblCity tblCity)
        {
            if (ModelState.IsValid)
            {
                db.tblCities.Add(tblCity);
                db.SaveChanges();
                return(RedirectToAction("Create", "Locals"));
            }

            return(View(tblCity));
        }
コード例 #28
0
        public string GetCity(Guid cityId)
        {
            using (WorkWithMeDataContext oDC = new WorkWithMeDataContext())
            {
                tblCity city = (from c in oDC.tblCities where c.Id == Id select c).FirstOrDefault();

                CityName = city.CityName;

                return(CityName);
            }
        }
コード例 #29
0
        public bool IsCityExists(City city)
        {
            bool    cityexists = false;
            tblCity cityObject = bringlyEntities.tblCities.Where(x => x.IsDeleted == false && x.CityName == city.CityName && x.CityGuid != city.CityGuid).FirstOrDefault();

            if (cityObject != null && !string.IsNullOrEmpty(cityObject.CityName))
            {
                cityexists = true;
            }
            return(cityexists);
        }
コード例 #30
0
        public ActionResult Delete(int?id)
        {
            tblCity   C = db.tblCities.SingleOrDefault(x => x.intCityId == id);
            CityModel N = new CityModel()
            {
                CityId   = C.intCityId,
                CityName = C.strCityName,
            };

            return(View(N));
        }
コード例 #31
0
ファイル: Data.Designer.cs プロジェクト: ramrcram/CornerSites
 /// <summary>
 /// Create a new tblCity object.
 /// </summary>
 /// <param name="cityID">Initial value of CityID.</param>
 public static tblCity CreatetblCity(short cityID)
 {
     tblCity tblCity = new tblCity();
     tblCity.CityID = cityID;
     return tblCity;
 }
コード例 #32
0
ファイル: Data.Designer.cs プロジェクト: ramrcram/CornerSites
 /// <summary>
 /// There are no comments for tblCity in the schema.
 /// </summary>
 public void AddTotblCity(tblCity tblCity)
 {
     base.AddObject("tblCity", tblCity);
 }