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));
            }
        }
Пример #2
0
 public ActionResult ContactUs(ContactUs par)
 {
     if (!ModelState.IsValid)
     {
         ViewBag.msgError = fn.fg.DataIsntValid;
     }
     else
     {
         var isSave = repo.Add(par);
         if (isSave == true)
         {
             ViewBag.msgSuccess = fn.fg.Save;
         }
         else
         {
             ViewBag.msgError = fn.fg.SFailed;
         }
     }
     return(View("ContactUs"));
 }