public HttpResponseMessage GetManagerCategoryById(HttpRequestMessage reqObject)
        {
            string ManagerCategoryId = string.Empty;

            _requestedDataObject = _IDataManipulation.GetRequestedDataObject(reqObject);
            if (_requestedDataObject != null && _requestedDataObject.BusinessData != null)
            {
                _ManagerCategory  = JsonConvert.DeserializeObject <ManCategory>(_requestedDataObject.BusinessData);
                ManagerCategoryId = _ManagerCategory.ManagerCategoryId;
            }

            if (!string.IsNullOrWhiteSpace(ManagerCategoryId))
            {
                _ManagerCategory = new ManCategory();
                _ManagerCategory = _IManagerCategoryService.GetManagerCategoryById(ManagerCategoryId);
            }
            if (_ManagerCategory != null)
            {
                _serviceResponse = _IDataManipulation.ResopnseWhenDataFound(_ManagerCategory, "information has been fetched successfully");
            }
            else
            {
                _serviceResponse = _IDataManipulation.ResopnseWhenDataNotFound("Manager Group Not Found...");
            }
            _response = _IDataManipulation.CreateResponse(_serviceResponse, reqObject);
            return(_response);
        }
        public HttpResponseMessage DeleteManagerCategory(HttpRequestMessage reqObject)
        {
            int result = 0;

            _requestedDataObject = _IDataManipulation.GetRequestedDataObject(reqObject);
            if (_requestedDataObject != null && _requestedDataObject.BusinessData != null)
            {
                _ManagerCategory = JsonConvert.DeserializeObject <ManCategory>(_requestedDataObject.BusinessData);
            }

            if (_ManagerCategory == null || string.IsNullOrWhiteSpace(_ManagerCategory.ManagerCategoryId))
            {
                _serviceResponse = _IDataManipulation.SetResponseObject(result, "Manager Not Found...");
                _response        = _IDataManipulation.CreateResponse(_serviceResponse, reqObject);
                return(_response);
            }

            result = _IManagerCategoryService.DeleteManagerCategory(_ManagerCategory);
            if (result == 1)
            {
                _serviceResponse = _IDataManipulation.SetResponseObject(result, "information has been deleted successfully");
            }
            else
            {
                _serviceResponse = _IDataManipulation.SetResponseObject(result, "information hasn't been deleted");
            }
            _response = _IDataManipulation.CreateResponse(_serviceResponse, reqObject);
            return(_response);
        }
        public HttpResponseMessage UpdateManagerCategory(HttpRequestMessage reqObject)
        {
            int result = 0;

            _requestedDataObject = _IDataManipulation.GetRequestedDataObject(reqObject);
            if (_requestedDataObject != null && _requestedDataObject.BusinessData != null)
            {
                _ManagerCategory = JsonConvert.DeserializeObject <ManCategory>(_requestedDataObject.BusinessData);
                bool IsValid = ModelValidation.TryValidateModel(_ManagerCategory, out _modelErrorMsg);
                if (IsValid)
                {
                    result = _IManagerCategoryService.UpdateManagerCategory(_ManagerCategory);
                }
            }

            if (!string.IsNullOrWhiteSpace(_modelErrorMsg))
            {
                _serviceResponse = _IDataManipulation.SetResponseObject(result, _modelErrorMsg);
            }
            else if (result == 1)
            {
                _serviceResponse = _IDataManipulation.SetResponseObject(result, "information has been updated successfully");
            }
            else
            {
                _serviceResponse = _IDataManipulation.SetResponseObject(result, "information hasn't been updated");
            }
            _response = _IDataManipulation.CreateResponse(_serviceResponse, reqObject);
            return(_response);
        }
Exemplo n.º 4
0
        public int AddManagerCategory(ManCategory _ManCategory)
        {
            try
            {
                var _max = _IUoW.Repository <ManCategory>().GetMaxValue(x => x.ManagerCategoryId) + 1;
                _ManCategory.ManagerCategoryId = _max.ToString().PadLeft(3, '0');
                _ManCategory.AuthStatusId      = "U";
                _ManCategory.LastAction        = "ADD";
                _ManCategory.MakeDT            = System.DateTime.Now;
                _ManCategory.MakeBy            = "mtaka";
                var result = _IUoW.Repository <ManCategory>().Add(_ManCategory);

                #region Auth Log
                if (result == 1)
                {
                    _IAuthLogService = new AuthLogService();
                    long _outMaxSlAuthLogDtl = 0;
                    _IAuthLogService.AddAuthLog(_IUoW, null, _ManCategory, "ADD", "0001", _ManCategory.FunctionId, 1, "ManCategory", "MTK_SP_MAN_CATEGORY", "ManCategoryId", _ManCategory.ManagerCategoryId, _ManCategory.UserName, _outMaxSlAuthLogDtl, out _outMaxSlAuthLogDtl);
                    //_IAuthLogService.AddAuthLog(_IUoW, null, ListTest, "ADD", "0001", "010101002", 0, "TEST", "ID", null, "mtaka", _outMaxSlAuthLogDtl, out _outMaxSlAuthLogDtl);
                }
                #endregion

                if (result == 1)
                {
                    _IUoW.Commit();
                }
                return(result);
            }
            catch (Exception ex)
            {
                _ObjErrorLogService = new ErrorLogService();
                _ObjErrorLogService.AddErrorLog(ex, string.Empty, "AddManagerCategory(obj)", string.Empty);
                return(0);
            }
        }
Exemplo n.º 5
0
 public ManCategory GetManagerCategoryBy(ManCategory ManCategory)
 {
     try
     {
         if (ManCategory == null)
         {
             return(ManCategory);
         }
         return(_IUoW.Repository <ManCategory>().GetBy(x => x.ManagerCategoryId == ManCategory.ManagerCategoryId &&
                                                       x.AuthStatusId != "D" &&
                                                       x.LastAction != "DEL"));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 6
0
        public int DeleteManagerCategory(ManCategory _ManCategory)
        {
            try
            {
                int  result = 0;
                bool IsRecordExist;
                if (!string.IsNullOrWhiteSpace(_ManCategory.ManagerCategoryId))
                {
                    IsRecordExist = _IUoW.Repository <ManCategory>().IsRecordExist(x => x.ManagerCategoryId == _ManCategory.ManagerCategoryId);
                    if (IsRecordExist)
                    {
                        var _oldManCategory       = _IUoW.Repository <ManCategory>().GetBy(x => x.ManagerCategoryId == _ManCategory.ManagerCategoryId);
                        var _oldManCategoryForLog = ObjectCopier.DeepCopy(_oldManCategory);

                        _oldManCategory.AuthStatusId = _ManCategory.AuthStatusId = "U";
                        _oldManCategory.LastAction   = _ManCategory.LastAction = "DEL";
                        _oldManCategory.LastUpdateDT = _ManCategory.LastUpdateDT = System.DateTime.Now;
                        result = _IUoW.Repository <ManCategory>().Update(_oldManCategory);

                        #region Auth Log
                        if (result == 1)
                        {
                            _IAuthLogService = new AuthLogService();
                            long _outMaxSlAuthLogDtl = 0;
                            _IAuthLogService.AddAuthLog(_IUoW, _oldManCategoryForLog, _ManCategory, "DEL", "0001", _ManCategory.FunctionId, 1, "ManCategory", "MTK_SP_MAN_CATEGORY", "ManagerCategoryId", _ManCategory.ManagerCategoryId, _ManCategory.UserName, _outMaxSlAuthLogDtl, out _outMaxSlAuthLogDtl);
                        }
                        #endregion

                        if (result == 1)
                        {
                            _IUoW.Commit();
                        }
                        return(result);
                    }
                    //result = _IUoW.Repository<ManCategory>().Delete(_ManCategory);
                    return(result);
                }
                return(result);
            }
            catch (Exception ex)
            {
                _ObjErrorLogService = new ErrorLogService();
                _ObjErrorLogService.AddErrorLog(ex, string.Empty, "DeleteManagerCategory(obj)", string.Empty);
                return(0);
            }
        }
 public HttpResponseMessage GetManagerCategoryBy(HttpRequestMessage reqObject)
 {
     _requestedDataObject = _IDataManipulation.GetRequestedDataObject(reqObject);
     if (_requestedDataObject != null && _requestedDataObject.BusinessData != null)
     {
         _ManagerCategory = JsonConvert.DeserializeObject <ManCategory>(_requestedDataObject.BusinessData);
         _ManagerCategory = _IManagerCategoryService.GetManagerCategoryBy(_ManagerCategory);
     }
     if (_ManagerCategory != null)
     {
         _serviceResponse = _IDataManipulation.ResopnseWhenDataFound(_ManagerCategory, "information has been fetched successfully");
     }
     else
     {
         _serviceResponse = _IDataManipulation.ResopnseWhenDataNotFound("Manager Group Not Found...");
     }
     _response = _IDataManipulation.CreateResponse(_serviceResponse, reqObject);
     return(_response);
 }