示例#1
0
        public ActionResult Add(DOADM_AlertDetails objDOADM_AlertDetails)
        {
            string         errorMessage  = string.Empty;
            long           loginUserId   = currentUser.ADM_UserMasterId;
            string         returnMessage = "";
            ExceptionTypes result        = new ExceptionTypes();

            try
            {
                //check if this call is to update record or save new record
                if (objDOADM_AlertDetails.ADM_AlertDetailsId > 0)
                {
                    //if old record is to be updated
                    BLCommon objCommon = new BLCommon();
                    //check if record is locked by current user
                    if (!objCommon.ValidateLockBeforeSave(loginUserId, (long)ScreenType.Alerts, objDOADM_AlertDetails.ADM_AlertDetailsId))
                    {
                        //if record is not locked by current user dont save record and return error.
                        errorMessage = "Record not locked, please reload the page.";
                        result       = ExceptionTypes.UnknownError;
                        return(Json(new { ID = result, Message = errorMessage }));
                    }

                    returnMessage = "Record updated successfully.";
                }
                else
                {
                    //If new record to be saved
                    returnMessage = "Record saved successfully.";
                }
                objDOADM_AlertDetails.LoginUserId = loginUserId;
                result = _objBLAlerts.SaveAlert(objDOADM_AlertDetails, out errorMessage);
                //check result for DB action
                if (result != (long)ExceptionTypes.Success)
                {
                    BLCommon.LogError(currentUser.ADM_UserMasterId, MethodBase.GetCurrentMethod().Name, (long)ErrorModuleName.Alerts, (long)ExceptionTypes.Uncategorized, errorMessage, errorMessage);
                    return(Json(new { ID = result, Message = "An error occured while updating DB." }));
                }
                return(Json(new { ID = result, Message = returnMessage }));
            }
            catch (Exception ex)
            {
                BLCommon.LogError(currentUser.ADM_UserMasterId, MethodBase.GetCurrentMethod().Name, (long)ErrorModuleName.Alerts, (long)ExceptionTypes.Uncategorized, ex.ToString(), ex.ToString());
                return(Json(new { ID = result, Message = "An error occured while updating DB." }));
            }
        }