コード例 #1
0
        public ActionResult Edit(DataSourcesEditModel model)
        {
            if (ModelState.IsValid)
            {
                short sysMessageId     = 0;
                byte  sysMessageTypeId = 0;
                model.SystemStatus = SystemStatus.Error;
                var dataSource = new DataSources()
                {
                    DataSourceId   = model.DataSourceId,
                    DataSourceName = model.DataSourceName,
                    DataSourceDesc = model.DataSourceDesc,
                    DataTypeId     = model.DataTypeId,
                    DisplayOrder   = model.DisplayOrder,
                    CrUserId       = model.CrUserId,
                    CrDateTime     = model.CrDateTime
                };
                sysMessageTypeId = model.DataSourceId > 0 ? dataSource.Update(0, _userId, ref sysMessageId) : dataSource.Insert(0, _userId, ref sysMessageId);

                if (sysMessageId > 0)
                {
                    var sysMessage = new SystemMessages().Get(sysMessageId);
                    if (sysMessageTypeId == CmsConstants.SystemMessageIdSuccess)
                    {
                        model.SystemStatus = SystemStatus.Success;
                    }
                    ModelState.AddModelError("SystemMessages", sysMessage.SystemMessageDesc);
                }
                else
                {
                    ModelState.AddModelError("SystemMessages", "Bạn vui lòng thử lại sau.");
                }
            }
            return(View(model));
        }
コード例 #2
0
        public ActionResult Edit(short dataSourceId = 0)
        {
            var model = new DataSourcesEditModel();

            if (dataSourceId > 0)
            {
                var dataSource = new DataSources {
                    DataSourceId = dataSourceId
                }.Get(dataSourceId);
                if (dataSource.DataSourceId > 0)
                {
                    model.DataSourceId   = dataSource.DataSourceId;
                    model.DataTypeId     = dataSource.DataTypeId;
                    model.DataSourceName = dataSource.DataSourceName;
                    model.DataSourceDesc = dataSource.DataSourceDesc;
                    model.DisplayOrder   = dataSource.DisplayOrder;
                    model.CrUserId       = dataSource.CrUserId;
                    model.CrDateTime     = dataSource.CrDateTime;
                }
            }
            return(View(model));
        }