Пример #1
0
        private static string CreateOrUpdate(DevelopmentCategoryDataModel data, RequestProfile requestProfile, string action)
        {
            var sql = "EXEC ";

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

            case "Update":
                sql += "dbo.DevelopmentCategoryUpdate  " + "\r\n" +
                       " " + ToSQLParameter(BaseDataModel.BaseDataColumns.AuditId, requestProfile.AuditId);
                break;

            default:
                break;
            }

            sql = sql + ", " + ToSQLParameter(data, StandardDataModel.StandardDataColumns.Name) +
                  ", " + ToSQLParameter(data, DevelopmentCategoryDataModel.DataColumns.DevelopmentCategoryId) +
                  ", " + ToSQLParameter(data, StandardDataModel.StandardDataColumns.Description) +
                  ", " + ToSQLParameter(data, StandardDataModel.StandardDataColumns.SortOrder);

            return(sql);
        }
Пример #2
0
        public ActionResult Index2(string searchString, int?page, int?pageSize)
        {
            var obj = new DevelopmentCategoryDataModel();

            obj.Name = searchString;
            var list = DevelopmentCategoryDataManager.GetEntitySearch(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));
        }
Пример #3
0
        public static int Create(DevelopmentCategoryDataModel data, RequestProfile requestProfile)
        {
            var sql = CreateOrUpdate(data, requestProfile, "Create");

            var DevelopmentCategoryId = DBDML.RunScalarSQL("DevelopmentCategory.Insert", sql, DataStoreKey);

            return(Convert.ToInt32(DevelopmentCategoryId));
        }
Пример #4
0
        static public List <DevelopmentCategoryDataModel> GetEntitySearch(DevelopmentCategoryDataModel obj, RequestProfile requestProfile)
        {
            var dt = Search(obj, requestProfile);

            var list = ToList(dt);

            return(list);
        }
Пример #5
0
        public static DataTable Search(DevelopmentCategoryDataModel data, RequestProfile requestProfile)
        {
            var list = GetEntityDetails(data, requestProfile);

            var table = list.ToDataTable();

            return(table);
        }
Пример #6
0
        public static DataTable DoesExist(DevelopmentCategoryDataModel data, RequestProfile requestProfile)
        {
            var doesExistRequest = new DevelopmentCategoryDataModel();

            doesExistRequest.Name = data.Name;

            return(Search(doesExistRequest, requestProfile));
        }
Пример #7
0
        public JsonResult IndexResult(string name, int?page, int?pageSize)
        {
            var obj = new DevelopmentCategoryDataModel();

            obj.Name = name;
            var list = DevelopmentCategoryDataManager.GetEntitySearch(obj, SessionVariables.RequestProfile);

            return(Json(list, JsonRequestBehavior.AllowGet));
        }
Пример #8
0
        public static bool DoesExist(DevelopmentCategoryDataModel data, RequestProfile requestProfile)
        {
            var doesExistRequest = new DevelopmentCategoryDataModel();

            doesExistRequest.Name = data.Name;

            var list = GetEntityDetails(doesExistRequest, requestProfile);

            return(list.Count > 0);
        }
Пример #9
0
        public ActionResult Create(DevelopmentCategoryDataModel obj)
        {
            if (ModelState.IsValid)
            {
                DevelopmentCategoryDataManager.Create(obj, SessionVariables.RequestProfile);
                return(RedirectToAction("Index"));
            }

            return(View(obj));
        }
Пример #10
0
        public DevelopmentCategoryDataModel GetById(int id)
        {
            var obj = new DevelopmentCategoryDataModel();

            obj.DevelopmentCategoryId = id;
            var list = DevelopmentCategoryDataManager.GetEntityDetails(obj, SessionVariables.RequestProfile);

            if (list == null || list.Count == 0)
            {
                return(null);
            }
            return(list[0]);
        }
Пример #11
0
        public static void Delete(DevelopmentCategoryDataModel data, RequestProfile requestProfile)
        {
            const string sql = @"dbo.DevelopmentCategoryDelete ";

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

            using (var dataAccess = new DataAccessBase(DataStoreKey))
            {
                dataAccess.Connection.Execute(sql, parameters, commandType: CommandType.StoredProcedure);
            }
        }
Пример #12
0
        static private List <DevelopmentCategoryDataModel> ToList(DataTable dt)
        {
            var list = new List <DevelopmentCategoryDataModel>();

            if (dt != null && dt.Rows.Count > 0)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    var dataItem = new DevelopmentCategoryDataModel();

                    dataItem.DevelopmentCategoryId = (int?)dr[DevelopmentCategoryDataModel.DataColumns.DevelopmentCategoryId];
                    dataItem.DateCreated           = (DateTime)dr[DevelopmentCategoryDataModel.DataColumns.DateCreated];
                    dataItem.DateModified          = (DateTime)dr[DevelopmentCategoryDataModel.DataColumns.DateModified];
                    dataItem.CreatedByAuditId      = (int?)dr[DevelopmentCategoryDataModel.DataColumns.CreatedByAuditId];
                    dataItem.ModifiedByAuditId     = (int?)dr[DevelopmentCategoryDataModel.DataColumns.ModifiedByAuditId];

                    SetStandardInfo(dataItem, dr);

                    list.Add(dataItem);
                }
            }
            return(list);
        }
Пример #13
0
        public static List <DevelopmentCategoryDataModel> GetEntityDetails(DevelopmentCategoryDataModel dataQuery, RequestProfile requestProfile)
        {
            const string sql = @"dbo.DevelopmentCategorySearch ";

            var parameters =
                new
            {
                AuditId                 = requestProfile.AuditId
                , ApplicationId         = requestProfile.ApplicationId
                , Name                  = dataQuery.Name
                , Description           = dataQuery.Description
                , DevelopmentCategoryId = dataQuery.DevelopmentCategoryId
                , ApplicationMode       = requestProfile.ApplicationModeId
            };

            List <DevelopmentCategoryDataModel> result;

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

            return(result);
        }
Пример #14
0
        public static void Update(DevelopmentCategoryDataModel data, RequestProfile requestProfile)
        {
            var sql = CreateOrUpdate(data, requestProfile, "Update");

            DBDML.RunSQL("DevelopmentCategory.Update", sql, DataStoreKey);
        }
Пример #15
0
        public static string ToSQLParameter(DevelopmentCategoryDataModel data, string dataColumnName)
        {
            var returnValue = "NULL";

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

            case DevelopmentCategoryDataModel.DataColumns.DateCreated:
                if (data.DateCreated != null)
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_STRING_OR_DATE, DevelopmentCategoryDataModel.DataColumns.DateCreated, data.DateCreated);
                }
                else
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, DevelopmentCategoryDataModel.DataColumns.DateCreated);
                }
                break;

            case DevelopmentCategoryDataModel.DataColumns.DateModified:
                if (data.DateModified != null)
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_STRING_OR_DATE, DevelopmentCategoryDataModel.DataColumns.DateModified, data.DateModified);
                }
                else
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, DevelopmentCategoryDataModel.DataColumns.DateModified);
                }
                break;

            case DevelopmentCategoryDataModel.DataColumns.CreatedByAuditId:
                if (data.CreatedByAuditId != null)
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NUMBER, DevelopmentCategoryDataModel.DataColumns.CreatedByAuditId, data.CreatedByAuditId);
                }
                else
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, DevelopmentCategoryDataModel.DataColumns.CreatedByAuditId);
                }
                break;


            case DevelopmentCategoryDataModel.DataColumns.ModifiedByAuditId:
                if (data.ModifiedByAuditId != null)
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NUMBER, DevelopmentCategoryDataModel.DataColumns.ModifiedByAuditId, data.ModifiedByAuditId);
                }
                else
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, DevelopmentCategoryDataModel.DataColumns.ModifiedByAuditId);
                }
                break;


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

            return(returnValue);
        }
Пример #16
0
        public static DevelopmentCategoryDataModel GetDetails(DevelopmentCategoryDataModel data, RequestProfile requestProfile)
        {
            var list = GetEntityDetails(data, requestProfile);

            return(list.FirstOrDefault());
        }