Exemple #1
0
        public JsonResult DeleteCustomerContact(int customerContactId)
        {
            Logger.Info(_logMsg.Clear().SetPrefixMsg("Delete Contact").Add("ContactId", customerContactId).ToInputLogString());

            try
            {
                _customerFacade = new CustomerFacade();
                bool isSuccess = _customerFacade.DeleteCustomerContact(customerContactId, this.UserInfo.UserId);

                if (isSuccess)
                {
                    return(Json(new
                    {
                        Valid = true
                    }));
                }

                Logger.Info(_logMsg.Clear().SetPrefixMsg("Delete Contact").ToFailLogString());
                return(Json(new
                {
                    Valid = false,
                    Error = "ไม่สามารถลบข้อมูลได้ เนื่องจากมีการใช้งานข้อมูลอยู่",
                    Errors = string.Empty
                }));
            }
            catch (Exception ex)
            {
                Logger.Error("Exception occur:\n", ex);
                Logger.Info(_logMsg.Clear().SetPrefixMsg("Delete Contact").Add("Error Message", ex.Message).ToFailLogString());
                return(Json(new
                {
                    Valid = false,
                    Error = Resource.Error_System,
                    Errors = string.Empty
                }));
            }
        }