Beispiel #1
0
        public static int Create(CustomTimeCategoryDataModel data, RequestProfile requestProfile)
        {
            var sql   = Save(data, "Create", requestProfile);
            var newId = DBDML.RunScalarSQL("CustomTimeCategory.Insert", sql, DataStoreKey);

            return(Convert.ToInt32(newId));
        }
Beispiel #2
0
        public static string Save(CustomTimeCategoryDataModel data, string action, RequestProfile requestProfile)
        {
            var sql = "EXEC ";

            switch (action)
            {
            case "Create":
                sql += "dbo.CustomTimeCategoryInsert  " +
                       " " + ToSQLParameter(BaseDataModel.BaseDataColumns.AuditId, requestProfile.AuditId) +
                       ", " + ToSQLParameter(BaseDataModel.BaseDataColumns.ApplicationId, requestProfile.ApplicationId);
                break;

            case "Update":
                sql += "dbo.CustomTimeCategoryUpdate  " +
                       " " + ToSQLParameter(BaseDataModel.BaseDataColumns.AuditId, requestProfile.AuditId);
                break;

            default:
                break;
            }
            sql = sql + ", " + ToSQLParameter(data, CustomTimeCategoryDataModel.DataColumns.CustomTimeCategoryId) +
                  ", " + ToSQLParameter(data, StandardDataModel.StandardDataColumns.Name) +
                  ", " + ToSQLParameter(data, StandardDataModel.StandardDataColumns.Description) +
                  ", " + ToSQLParameter(data, StandardDataModel.StandardDataColumns.SortOrder);

            return(sql);
        }
Beispiel #3
0
        //
        // GET: /ReleaseNoteBusinessDifficulty/
        public ActionResult Index(string searchString, int?page, int?pageSize)
        {
            var obj = new CustomTimeCategoryDataModel();

            obj.Name = searchString;
            var list = CustomTimeCategoryDataManager.GetEntityDetails(obj, SessionVariables.RequestProfile);

            if (pageSize.HasValue)
            {
                SessionVariables.DefaultRowCount = pageSize.Value;
            }

            int pageNumber = (page - 1 ?? 0);

            ViewBag.searchString = searchString;

            ViewBag.CurrentPage = list.Count > 0 ? pageNumber + 1 : 0;
            ViewBag.TotalPages  = list.Count / SessionVariables.DefaultRowCount;
            if (list.Count % SessionVariables.DefaultRowCount != 0)
            {
                ViewBag.TotalPages = (list.Count / SessionVariables.DefaultRowCount) + 1;
            }

            list = list.Count > 0 ? list.Skip(pageNumber * SessionVariables.DefaultRowCount).Take(SessionVariables.DefaultRowCount).ToList() : list;
            return(View(list));
        }
Beispiel #4
0
        public static DataSet GetChildren(CustomTimeCategoryDataModel data, RequestProfile requestProfile)
        {
            var sql = "EXEC dbo.CustomTimeCategoryChildrenGet" +
                      " " + ToSQLParameter(BaseDataModel.BaseDataColumns.AuditId, requestProfile.AuditId) +
                      ", " + ToSQLParameter(data, CustomTimeCategoryDataModel.DataColumns.CustomTimeCategoryId);
            var oDT = new Framework.Components.DataAccess.DBDataSet("Get Children", sql, DataStoreKey);

            return(oDT.DBDataset);
        }
Beispiel #5
0
        public ActionResult Create(CustomTimeCategoryDataModel obj)
        {
            if (ModelState.IsValid)
            {
                CustomTimeCategoryDataManager.Create(obj, SessionVariables.RequestProfile);
                return(RedirectToAction("Index"));
            }

            return(View(obj));
        }
Beispiel #6
0
        public static bool DoesExist(CustomTimeCategoryDataModel data, RequestProfile requestProfile)
        {
            var doesExistRequest = new CustomTimeCategoryDataModel();

            doesExistRequest.ApplicationId = data.ApplicationId;
            doesExistRequest.Name          = data.Name;

            var list = GetEntityDetails(doesExistRequest, requestProfile, 0);

            return(list.Count > 0);
        }
Beispiel #7
0
        public CustomTimeCategoryDataModel GetById(int id)
        {
            var obj = new CustomTimeCategoryDataModel();

            obj.CustomTimeCategoryId = id;
            var list = CustomTimeCategoryDataManager.GetEntityDetails(obj, SessionVariables.RequestProfile);

            if (list == null || list.Count == 0)
            {
                return(null);
            }
            return(list[0]);
        }
Beispiel #8
0
        public static void Delete(CustomTimeCategoryDataModel data, RequestProfile requestProfile)
        {
            const string sql = @"dbo.CustomTimeCategoryDelete ";

            var parameters =
                new
            {
                AuditId = requestProfile.AuditId
                , CustomTimeCategoryId = data.CustomTimeCategoryId
            };

            using (var dataAccess = new DataAccessBase(DataStoreKey))
            {
                dataAccess.Connection.Execute(sql, parameters, commandType: CommandType.StoredProcedure);
            }
        }
Beispiel #9
0
        public static bool IsDeletable(CustomTimeCategoryDataModel data, RequestProfile requestProfile)
        {
            var isDeletable = true;
            var ds          = GetChildren(data, requestProfile);

            if (ds != null && ds.Tables.Count > 0)
            {
                foreach (DataTable dt in ds.Tables)
                {
                    if (dt.Rows.Count > 0)
                    {
                        isDeletable = false;
                        break;
                    }
                }
            }
            return(isDeletable);
        }
Beispiel #10
0
        public static List <CustomTimeCategoryDataModel> GetEntityDetails(CustomTimeCategoryDataModel dataQuery, RequestProfile requestProfile, int returnAuditInfo = BaseDataManager.ReturnAuditInfoOnDetails)
        {
            const string sql = @"dbo.CustomTimeCategorySearch ";

            var parameters =
                new
            {
                AuditId                = requestProfile.AuditId
                , ApplicationId        = requestProfile.ApplicationId
                , ApplicationMode      = requestProfile.ApplicationModeId
                , ReturnAuditInfo      = returnAuditInfo
                , CustomTimeCategoryId = dataQuery.CustomTimeCategoryId
                , Name = dataQuery.Name
            };

            List <CustomTimeCategoryDataModel> result;

            using (var dataAccess = new DataAccessBase(DataStoreKey))
            {
                result = dataAccess.Connection.Query <CustomTimeCategoryDataModel>(sql, parameters, commandType: CommandType.StoredProcedure).ToList();
            }

            return(result);
        }
Beispiel #11
0
        public static string ToSQLParameter(CustomTimeCategoryDataModel data, string dataColumnName)
        {
            var returnValue = "NULL";

            switch (dataColumnName)
            {
            case CustomTimeCategoryDataModel.DataColumns.CustomTimeCategoryId:
                if (data.CustomTimeCategoryId != null)
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NUMBER, CustomTimeCategoryDataModel.DataColumns.CustomTimeCategoryId, data.CustomTimeCategoryId);
                }
                else
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, CustomTimeCategoryDataModel.DataColumns.CustomTimeCategoryId);
                }
                break;

            default:
                returnValue = StandardDataManager.ToSQLParameter(data, dataColumnName);
                break;
            }

            return(returnValue);
        }
Beispiel #12
0
        public IEnumerable <CustomTimeCategoryDataModel> GetListCustomTimeCategory()
        {
            var dataQuery = new CustomTimeCategoryDataModel();

            return(CustomTimeCategoryDataManager.GetEntityDetails(dataQuery, SessionVariables.RequestProfile));
        }
Beispiel #13
0
        public static DataTable Search(CustomTimeCategoryDataModel data, RequestProfile requestProfile)
        {
            var list = GetEntityDetails(data, requestProfile, 0);

            return(list.ToDataTable());
        }
Beispiel #14
0
        public static void Update(CustomTimeCategoryDataModel data, RequestProfile requestProfile)
        {
            var sql = Save(data, "Update", requestProfile);

            DBDML.RunSQL("CustomTimeCategory.Update", sql, DataStoreKey);
        }
Beispiel #15
0
        public static CustomTimeCategoryDataModel GetDetails(CustomTimeCategoryDataModel data, RequestProfile requestProfile)
        {
            var list = GetEntityDetails(data, requestProfile, 1);

            return(list.FirstOrDefault());
        }