public ActionResult SaveLookup([FromBody] JObject data)
        {
            bool       res    = false;
            int        lType  = data["lType"].ToObject <int>();
            BaseLookup lookup = data["lookup"].ToObject <BaseLookup>();

            if (lookup == null || string.IsNullOrEmpty(lookup.Name.Trim()))
            {
                return(Json(new { success = false, response = "Name Is Required!" }));
            }

            string MethodName = string.Empty;
            Type   type       = _lookupService.TypeById(lType);

            if (type != null)
            {
                var obj = typeof(JsonConvert).GetMethods().Where(x => x.Name == "DeserializeObject").ToList()[3].MakeGenericMethod(type)
                          .Invoke(null, new [] { JsonConvert.SerializeObject(lookup) });

                if (lookup.Id > 0)
                {
                    MethodName = "UpdateLookup";
                }
                else
                {
                    MethodName = "AddLookup";
                }

                res = (bool)typeof(LookupService).GetMethod(MethodName).MakeGenericMethod(type).Invoke(_lookupService, new object[] { obj });
            }

            return(Json(new { success = res, response = res ? "Saved Successfully!" : "Error Whrn Delete!" }));
        }
Exemplo n.º 2
0
 public int?LookupDaysSupply(string key, string sqlFileDestination)
 {
     if (daysSupplyLookup == null)
     {
         daysSupplyLookup = new DaysSupplyLookup(Settings.Current.Building.SourceConnectionString,
                                                 sqlFileDestination, Settings.Current.Builder.Folder, Settings.Current.Building.SourceSchemaName);
         daysSupplyLookup.Load();
     }
     return((int?)daysSupplyLookup.LookupValue(key));
 }
        public ActionResult LoadLookupHeader(int lType, int Id)
        {
            BaseLookup model = null;
            Type       type  = _lookupService.TypeById(lType);

            if (type != null)
            {
                model = _mapper.Map <BaseLookup>(typeof(LookupService).GetMethod("GetLookup").MakeGenericMethod(type).Invoke(_lookupService, new object[] { Id }));
            }
            return(PartialView("Partial/LookupHeader", model));
        }
 public int IdByType(BaseLookup BL)
 {
     if (BL != null)
     {
         var @enum = Enum.GetValues(typeof(LookupTypeEnum));
         foreach (var item in @enum)
         {
             if (BL.GetType() == Type.GetType(Constatnts.LookupEntityModelsNameSpace + item.ToString()))
             {
                 return((int)item);
             }
         }
     }
     return(0);
 }
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            if (!ReadOnly)
            {
                if (!string.IsNullOrEmpty(OtherDataSourceLibrary) && !string.IsNullOrEmpty(OtherDataSourceView))
                {
                    throw new NotSupportedException();
                }

                if (!string.IsNullOrEmpty(SharedDataSourceName))
                {
                    var dataSource = new SharedDataSource <long>();
                    dataSource.DataSourceName = SharedDataSourceName;
                    LookupProjectName         = dataSource.BaseView.GetType().Assembly.FullName.Split(',')[0];
                    if (string.IsNullOrEmpty(dataSource.BaseView.TableName))
                    {
                        LookupTableName = dataSource.BaseView.TableType.Name;
                    }
                    else
                    {
                        LookupTableName = dataSource.BaseView.TableName;
                    }
                }

                Lookup = new BaseLookup
                {
                    ExtenderAjaxControl = ExtenderAjaxControl,
                    ProjectName         = LookupProjectName,
                    TableName           = LookupTableName,
                    Width               = new Unit(300, UnitType.Pixel),
                    IsMultipleSelect    = true,
                    SelectMode          = SelectMode,
                    MinimumPrefixLength = 2,
                    ID = "lookup",
                };
                Controls.Add(Lookup);
            }

            LoadItemsFromPostData();
        }