Commit 84ed809c by Liv Haapala

Merge branch 'master' of gitlab.codecrew.fi:liv/moya-info-tools

Conflicts:
	MoyaAdmin/MoyaAdminUI/MoyaAdminLib/obj/Debug/MoyaAdminLib.dll
	MoyaAdmin/MoyaAdminUI/MoyaAdminLib/obj/Debug/MoyaAdminLib.pdb
2 parents 86a0936b 51a5a0bc
......@@ -220,6 +220,8 @@ namespace MoyaAdminLib
}
public void Delete()
{
APIreference.Delete();
Cache.Remove(this);
}
public static List<ComputerPlace> Cache = new List<ComputerPlace>();
......
......@@ -67,6 +67,13 @@ namespace MoyaAdminUI.MoyaAPI
RestClient client = new RestClient(RestClient.ApiURL, HttpVerb.PUT);
string json = client.MakeRequest("placeadmin/place/" + id + "/reserve/" + userid);
}
public void Delete()
{
//ComputerPlace.Cache.Clear();
RestClient client = new RestClient(RestClient.ApiURL, HttpVerb.DELETE);
string json = client.MakeRequest("placeadmin/place/" + id);
}
}
}
......@@ -108,7 +108,7 @@ namespace MoyaAdminLib
request.ContentLength = 0;
request.ContentType = ContentType;
if (!string.IsNullOrEmpty(PostData) && (Method == HttpVerb.POST || Method == HttpVerb.PUT))
if (!string.IsNullOrEmpty(PostData) && (Method == HttpVerb.POST || Method == HttpVerb.PUT ))
{
var encoding = new UTF8Encoding();
var bytes = Encoding.GetEncoding("iso-8859-1").GetBytes(PostData);
......@@ -120,6 +120,9 @@ namespace MoyaAdminLib
}
}
try
{
using (var response = (HttpWebResponse)request.GetResponse())
{
var responseValue = string.Empty;
......@@ -133,20 +136,51 @@ namespace MoyaAdminLib
// grab the response
//if (response.ContentLength > 0)
//{
using (var responseStream = response.GetResponseStream())
{
if (responseStream != null)
using (var reader = new StreamReader(responseStream))
{
responseValue = reader.ReadToEnd();
}
}
using (var responseStream = response.GetResponseStream())
{
if (responseStream != null)
using (var reader = new StreamReader(responseStream))
{
responseValue = reader.ReadToEnd();
}
}
//}
return responseValue;
}
}
catch (WebException e)
{
Stream responseStream = ((WebException)e).Response.GetResponseStream();
if (responseStream != null)
{
string responseValue = StreamToString(responseStream);
Console.WriteLine("Response was " + responseValue);
throw new Exception(responseValue);
}
throw e;
}
}
/// <summary>
/// Convert streams from web to string
/// </summary>
/// <param name="responseStream">Webresponse stream</param>
/// <returns>string</returns>
private string StreamToString(Stream responseStream)
{
StreamReader reader = new StreamReader(responseStream);
string responseString = reader.ReadToEnd();
responseStream.Close();
reader.Close();
return responseString;
}
} // class
}
......@@ -13,3 +13,10 @@ I:\devel\proj\moya-info-tools\MoyaAdmin\MoyaAdminUI\MoyaAdminLib\obj\Debug\MoyaA
I:\devel\proj\moya-info-tools\MoyaAdmin\MoyaAdminUI\MoyaAdminLib\obj\Debug\MoyaAdminLib.csproj.GenerateResource.Cache
I:\devel\proj\moya-info-tools\MoyaAdmin\MoyaAdminUI\MoyaAdminLib\obj\Debug\MoyaAdminLib.dll
I:\devel\proj\moya-info-tools\MoyaAdmin\MoyaAdminUI\MoyaAdminLib\obj\Debug\MoyaAdminLib.pdb
D:\Devel\proj\moya-info-tools\moya-info-tools\MoyaAdmin\MoyaAdminUI\MoyaAdminLib\obj\Debug\MoyaAdminLib.Controls.EventUserEditor.resources
D:\Devel\proj\moya-info-tools\moya-info-tools\MoyaAdmin\MoyaAdminUI\MoyaAdminLib\obj\Debug\MoyaAdminLib.csproj.GenerateResource.Cache
D:\Devel\proj\moya-info-tools\moya-info-tools\MoyaAdmin\MoyaAdminUI\MoyaAdminLib\obj\Debug\MoyaAdminLib.dll
D:\Devel\proj\moya-info-tools\moya-info-tools\MoyaAdmin\MoyaAdminUI\MoyaAdminLib\bin\Debug\MoyaAdminLib.dll.config
D:\Devel\proj\moya-info-tools\moya-info-tools\MoyaAdmin\MoyaAdminUI\MoyaAdminLib\bin\Debug\MoyaAdminLib.dll
D:\Devel\proj\moya-info-tools\moya-info-tools\MoyaAdmin\MoyaAdminUI\MoyaAdminLib\bin\Debug\MoyaAdminLib.pdb
D:\Devel\proj\moya-info-tools\moya-info-tools\MoyaAdmin\MoyaAdminUI\MoyaAdminLib\obj\Debug\MoyaAdminLib.pdb
......@@ -20,6 +20,7 @@ namespace MoyaAdminUI
{
int newPlaceHeight = 10;
int newPlaceWidth = 10;
int defaultProductId = 470;
Point clickedLocation;
List<ComputerPlace> gridPreview = new List<ComputerPlace>();
ComputerPlaceGridSettings gridSettingsForm;
......@@ -304,7 +305,7 @@ namespace MoyaAdminUI
ComputerPlace place = new ComputerPlace();
place.MapId = SelectedMap.Id;
place.ProductId = 262;
place.ProductId = 470;
this.unsavedComputerPlaces.Add(place);
//place.Coord = location;
place.MapX = location.X;
......@@ -515,7 +516,7 @@ namespace MoyaAdminUI
ComputerPlace p = new ComputerPlace();
p.MapId = SelectedMap.Id;
p.ProductId = 262;
p.ProductId = defaultProductId;
p.Width = newPlaceWidth;
p.Height = newPlaceHeight;
int xcoord = 0;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!