コード例 #1
0
        public ApiGridResponse InsertDataCountry(TOURIS_TV_COUNTRY countryView)
        {
            ApiGridResponse res = new ApiGridResponse();
            ResultStatus    rs  = new ResultStatus();

            try
            {
                TOURIS_TM_COUNTRY country = new TOURIS_TM_COUNTRY();
                using (TourismpediaEntities tourisdb = new TourismpediaEntities())
                {
                    country.COUNTRY_CODE        = countryView.COUNTRY_CODE;
                    country.COUNTRY_NAME        = countryView.COUNTRY_NAME;
                    country.COUNTRY_DESCRIPTION = countryView.COUNTRY_DESCRIPTION;
                    country.CREATED_BY          = countryView.CREATED_BY;
                    country.CREATED_TIME        = countryView.CREATED_TIME;

                    tourisdb.TOURIS_TM_COUNTRY.Add(country);
                    tourisdb.SaveChanges();
                    rs.SetSuccessStatus();
                }
                res = ResGetDataTable(new object[] { rs }, null);
            }
            catch (Exception ex)
            {
                rs.SetErrorStatus(ex.Message);
                res = ResGetDataTable(new object[] { rs }, ex);
            }

            return(res);
        }
コード例 #2
0
        public ApiGridResponse DeleteDataCountry(TOURIS_TV_COUNTRY countryView)
        {
            ApiGridResponse res = new ApiGridResponse();
            ResultStatus    rs  = new ResultStatus();

            try
            {
                using (TourismpediaEntities tourisdb = new TourismpediaEntities())
                {
                    TOURIS_TM_COUNTRY country = tourisdb.TOURIS_TM_COUNTRY.Find(countryView.ID);

                    tourisdb.TOURIS_TM_COUNTRY.Remove(country);
                    tourisdb.SaveChanges();
                    rs.SetSuccessStatus();
                }
                res = ResGetDataTable(new object[] { rs }, null);
            }
            catch (Exception ex)
            {
                rs.SetErrorStatus(ex.Message);
                res = ResGetDataTable(new object[] { rs }, ex);
            }

            return(res);
        }
コード例 #3
0
        public ApiGridResponse EditDataCountry(TOURIS_TV_COUNTRY countryView)
        {
            ApiGridResponse res = new ApiGridResponse();
            ResultStatus    rs  = new ResultStatus();

            try
            {
                using (TourismpediaEntities tourisdb = new TourismpediaEntities())
                {
                    TOURIS_TM_COUNTRY country = tourisdb.TOURIS_TM_COUNTRY.Find(countryView.ID);
                    country.COUNTRY_CODE        = countryView.COUNTRY_CODE;
                    country.COUNTRY_NAME        = countryView.COUNTRY_NAME;
                    country.COUNTRY_DESCRIPTION = countryView.COUNTRY_DESCRIPTION;
                    country.LAST_MODIFIED_BY    = countryView.LAST_MODIFIED_BY;
                    country.LAST_MODIFIED_TIME  = countryView.LAST_MODIFIED_TIME;

                    tourisdb.Entry(country).State = EntityState.Modified;
                    tourisdb.SaveChanges();
                    rs.SetSuccessStatus();
                }
                res = ResGetDataTable(new object[] { rs }, null);
            }
            catch (Exception ex)
            {
                rs.SetErrorStatus(ex.Message);
                res = ResGetDataTable(new object[] { rs }, ex);
            }

            return(res);
        }
コード例 #4
0
        public IHttpActionResult RetrieveData(int id)
        {
            ApiResData res = new ApiResData();

            try
            {
                TOURIS_TM_COUNTRY country     = repo.Retrieve(id);
                TOURIS_TV_COUNTRY countryView = new TOURIS_TV_COUNTRY();

                if (country != null)
                {
                    countryView.ID                  = country.ID;
                    countryView.COUNTRY_CODE        = country.COUNTRY_CODE;
                    countryView.COUNTRY_NAME        = country.COUNTRY_NAME;
                    countryView.COUNTRY_DESCRIPTION = country.COUNTRY_DESCRIPTION;
                    countryView.CREATED_BY          = country.CREATED_BY;
                    countryView.CREATED_TIME        = country.CREATED_TIME;
                    countryView.LAST_MODIFIED_BY    = country.LAST_MODIFIED_BY;
                    countryView.LAST_MODIFIED_TIME  = country.LAST_MODIFIED_TIME;
                    rs.SetSuccessStatus();
                }
                resObj = JObject.FromObject(res.ResGetDataTable(new object[] { countryView }, null));

                return(Content(HttpStatusCode.OK, resObj));
            }
            catch (Exception ex)
            {
                rs.SetErrorStatus(ex.Message);
                resObj = JObject.FromObject(res.ResGetDataTable(new object[] { rs }, new Exception(eFunc.fg.DataNf)));
                return(Content(HttpStatusCode.BadRequest, resObj));
            }
        }
コード例 #5
0
        public ActionResult DeleteConfirmed(int id)
        {
            TOURIS_TM_COUNTRY tOURIS_TM_COUNTRY = db.TOURIS_TM_COUNTRY.Find(id);

            db.TOURIS_TM_COUNTRY.Remove(tOURIS_TM_COUNTRY);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #6
0
 public ActionResult Edit([Bind(Include = "ID,COUNTRY_NAME,COUNTRY_CODE,COUNTRY_DESCRIPTION,CREATED_TIME,CREATED_BY,LAST_MODIFIED_TIME,LAST_MODIFIED_BY,ROW_STATUS")] TOURIS_TM_COUNTRY tOURIS_TM_COUNTRY)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tOURIS_TM_COUNTRY).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(tOURIS_TM_COUNTRY));
 }
コード例 #7
0
        // GET: Country1/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TOURIS_TM_COUNTRY tOURIS_TM_COUNTRY = db.TOURIS_TM_COUNTRY.Find(id);

            if (tOURIS_TM_COUNTRY == null)
            {
                return(HttpNotFound());
            }
            return(View(tOURIS_TM_COUNTRY));
        }
コード例 #8
0
        public ResultStatus Add(TOURIS_TM_COUNTRY country)
        {
            try
            {
                _ctx.TOURIS_TM_COUNTRY.Add(country);
                _ctx.SaveChanges();
                rs.SetSuccessStatus();
            }
            catch (Exception ex)
            {
                rs.SetErrorStatus(ex.Message);
            }

            return(rs);
        }
コード例 #9
0
        public IHttpActionResult Add(TOURIS_TV_COUNTRY countryView)
        {
            ApiResData res = new ApiResData();

            try
            {
                if (!ModelState.IsValid)
                {
                    rs.SetErrorStatus(eFunc.fg.SFailed);
                    resObj = JObject.FromObject(res.ResCUD(new object[] { rs }, eFunc.fg.Save, new Exception(eFunc.fg.DataIsntValid)));
                    return(Content(HttpStatusCode.NotFound, resObj));
                }

                TOURIS_TM_COUNTRY country = new TOURIS_TM_COUNTRY();
                country.COUNTRY_CODE        = countryView.COUNTRY_CODE;
                country.COUNTRY_NAME        = countryView.COUNTRY_NAME;
                country.COUNTRY_DESCRIPTION = countryView.COUNTRY_DESCRIPTION;
                country.CREATED_BY          = countryView.CREATED_BY;
                country.CREATED_TIME        = countryView.CREATED_TIME;
                country.ROW_STATUS          = eStat.fg.IsActive;

                rs = repo.Add(country);
                if (rs.IsSuccess)
                {
                    rs.SetSuccessStatus();
                }
                else
                {
                    rs.SetErrorStatus(eFunc.fg.SFailed);
                }

                resObj = JObject.FromObject(res.ResCUD(new object[] { rs }, eFunc.fg.Save, null));

                return(Content(HttpStatusCode.OK, resObj));
            }
            catch (Exception ex)
            {
                rs.SetErrorStatus(ex.Message);
                resObj = JObject.FromObject(res.ResCUD(new object[] { rs }, eFunc.fg.Save, new Exception(eFunc.fg.SFailed)));
                return(Content(HttpStatusCode.BadRequest, resObj));
            }
        }
コード例 #10
0
        public ResultStatus Delete(int id, string modifiedBy, DateTime modifiedTime)
        {
            try
            {
                TOURIS_TM_COUNTRY country = _ctx.TOURIS_TM_COUNTRY.Find(id);
                country.LAST_MODIFIED_TIME = modifiedTime;
                country.LAST_MODIFIED_BY   = modifiedBy;
                country.ROW_STATUS         = eStat.fg.NotActive;

                _ctx.Entry(country).State = EntityState.Modified;
                _ctx.SaveChanges();
                rs.SetSuccessStatus();
            }
            catch (Exception ex)
            {
                rs.SetErrorStatus(ex.Message);
            }

            return(rs);
        }
コード例 #11
0
        public ResultStatus Edit(TOURIS_TM_COUNTRY country)
        {
            try
            {
                TOURIS_TM_COUNTRY countryNew = _ctx.TOURIS_TM_COUNTRY.Find(country.ID);
                countryNew.COUNTRY_CODE        = country.COUNTRY_CODE;
                countryNew.COUNTRY_NAME        = country.COUNTRY_NAME;
                countryNew.COUNTRY_DESCRIPTION = country.COUNTRY_DESCRIPTION;
                countryNew.LAST_MODIFIED_TIME  = country.LAST_MODIFIED_TIME;
                countryNew.LAST_MODIFIED_BY    = country.LAST_MODIFIED_BY;
                _ctx.Entry(countryNew).State   = System.Data.Entity.EntityState.Modified;
                _ctx.SaveChanges();
                rs.SetSuccessStatus();
            }
            catch (Exception ex)
            {
                rs.SetErrorStatus(ex.Message);
            }

            return(rs);
        }