protected void SaveButton_Click(object sender, EventArgs e) { Component application; Dictionary <string, Component> appListDic = new Dictionary <string, Component>(); appListDic = appList.ToDictionary <Component, string>(x => x.Id.ToString()); string appName = AppNameTxt.Value; string appID = AppIDTxt.Value; var selectedItems = from item in AppsDrpDown.Items.Cast <ListItem>() where item.Selected select appListDic[item.Value]; application = ComponentLogic.GetByAppId(appID); if (!isEdit) { application = new Component(); application.Status = AppStatus.Down; application.HeartBeatStatus = HeartBeatStatus.Down; } application.AppID = appID; application.AppName = appName; application.ChildrenComponents = selectedItems.ToList(); if (isEdit) { ComponentLogic.EditEntity(application); Response.Redirect("view-applications.html"); } else { ComponentLogic.AddNewEntity(application); Response.Redirect(Request.RawUrl); } }
protected void SaveButton_Click(object sender, EventArgs e) { Component application; Dictionary <string, Component> appListDic = new Dictionary <string, Component>(); appListDic = appList.ToDictionary <Component, string>(x => x.Id.ToString()); string appName = AppNameTxt.Value; string appID = string.Empty; // string appID = AppIDTxt.Value; if (!isEdit) { appID = new ComponentLogic().GenerateAppID(); } else { appID = Convert.ToString(Request.QueryString["appID"]); } var selectedItems = from item in AppsDrpDown.Items.Cast <ListItem>() where item.Selected select appListDic[item.Value]; string state; bool isExists = ComponentLogic.isExist(appID, appName, ID, out state); if (isExists) { ShowNotification(false, string.Format("An Application with this {0} already exists", state), ""); return; } application = ComponentLogic.GetByAppId(appID); if (!isEdit) { application = new Component(); application.Status = AppStatus.Down; application.HeartBeatStatus = HeartBeatStatus.Down; } application.AppID = appID; application.AppName = appName; application.ChildrenComponents = selectedItems.ToList(); if (isEdit) { ComponentLogic.EditEntity(application); ShowNotification(true, "Sucessfully Updated", "view-applications.html"); //Response.Redirect("view-applications.html"); } else { ComponentLogic.AddNewEntity(application); ShowNotification(true, string.Format("Sucessfully Created, APPLICATION ID: {0}", application.AppID), "AddApplication.aspx"); //Response.Redirect(Request.RawUrl); } }