public IHttpActionResult RetrieveData(int id)
        {
            ApiResData res = new ApiResData();

            try
            {
                TOURIS_TM_CONTACT_US contactUs     = repo.Retrieve(id);
                TOURIS_TV_CONTACT_US contactUsView = new TOURIS_TV_CONTACT_US();

                if (contactUs != null)
                {
                    contactUsView.ID                 = contactUs.ID;
                    contactUsView.NAME_SENDER        = contactUs.NAME_SENDER;
                    contactUsView.EMAIL_SENDER       = contactUs.EMAIL_SENDER;
                    contactUsView.PHONE_SENDER       = contactUs.PHONE_SENDER;
                    contactUsView.DESCRIPTION        = contactUs.DESCRIPTION;
                    contactUsView.CREATED_BY         = contactUs.CREATED_BY;
                    contactUsView.CREATED_TIME       = contactUs.CREATED_TIME;
                    contactUsView.LAST_MODIFIED_BY   = contactUs.LAST_MODIFIED_BY;
                    contactUsView.LAST_MODIFIED_TIME = contactUs.LAST_MODIFIED_TIME;
                    rs.SetSuccessStatus();
                }
                resObj = JObject.FromObject(res.ResGetDataTable(new object[] { contactUsView }, 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));
            }
        }
Example #2
0
        public ResultStatus Add(TOURIS_TM_CONTACT_US contactUs)
        {
            try
            {
                _ctx.TOURIS_TM_CONTACT_US.Add(contactUs);
                _ctx.SaveChanges();
                rs.SetSuccessStatus();
            }
            catch (Exception ex)
            {
                rs.SetErrorStatus(ex.Message);
            }

            return(rs);
        }
        public IHttpActionResult Add(TOURIS_TV_CONTACT_US contactUsView)
        {
            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_CONTACT_US contactUs = new TOURIS_TM_CONTACT_US();
                contactUs.NAME_SENDER  = contactUsView.NAME_SENDER;
                contactUs.EMAIL_SENDER = contactUsView.EMAIL_SENDER;
                contactUs.PHONE_SENDER = contactUsView.PHONE_SENDER;
                contactUs.DESCRIPTION  = contactUsView.DESCRIPTION;
                contactUs.CREATED_BY   = contactUsView.CREATED_BY;
                contactUs.CREATED_TIME = contactUsView.CREATED_TIME;
                contactUs.ROW_STATUS   = eStat.fg.IsActive;

                rs = repo.Add(contactUs);
                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));
            }
        }
Example #4
0
        public ResultStatus Delete(int id, string modifiedBy, DateTime modifiedTime)
        {
            try
            {
                TOURIS_TM_CONTACT_US contactUs = _ctx.TOURIS_TM_CONTACT_US.Find(id);
                contactUs.LAST_MODIFIED_TIME = modifiedTime;
                contactUs.LAST_MODIFIED_BY   = modifiedBy;
                contactUs.ROW_STATUS         = eStat.fg.NotActive;

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

            return(rs);
        }
Example #5
0
        public ResultStatus Edit(TOURIS_TM_CONTACT_US contactUs)
        {
            try
            {
                TOURIS_TM_CONTACT_US contactUsNew = _ctx.TOURIS_TM_CONTACT_US.Find(contactUs.ID);
                contactUsNew.NAME_SENDER        = contactUs.NAME_SENDER;
                contactUsNew.EMAIL_SENDER       = contactUs.EMAIL_SENDER;
                contactUsNew.PHONE_SENDER       = contactUs.EMAIL_SENDER;
                contactUsNew.DESCRIPTION        = contactUs.DESCRIPTION;
                contactUsNew.LAST_MODIFIED_TIME = contactUs.LAST_MODIFIED_TIME;
                contactUsNew.LAST_MODIFIED_BY   = contactUs.LAST_MODIFIED_BY;
                _ctx.Entry(contactUsNew).State  = System.Data.Entity.EntityState.Modified;
                _ctx.SaveChanges();
                rs.SetSuccessStatus();
            }
            catch (Exception ex)
            {
                rs.SetErrorStatus(ex.Message);
            }

            return(rs);
        }