public ServiceData Add(string name, string author, string code, int price, string id) { ServiceData myServiceData = new ServiceData(); try { if (id == null || !logged.ContainsKey(id)) { throw new FieldAccessException("User couldn't be verified"); } else { string value = ""; logged.TryGetValue(id, out value); if (value.Equals("admin")) { lock (Products) { int i = 0; for (i = 0; i < Products.Count && Products[i].Id != code; i++) { ; } if (i < Products.Count) { myServiceData.ErrorMessage = "Product Code Already Exists"; return(myServiceData); } else { if (price < 0) { myServiceData.ErrorMessage = "Price cannot be smaller than 0"; return(myServiceData); } Book current = new Book(name, author, code, price); writeRowToDatabase(current); myServiceData.Result = true; myServiceData.ErrorMessage = "OK, Added: " + name + " " + author + " " + code + " " + price; return(myServiceData); } } } else { myServiceData.ErrorMessage = "No Admin Privilage"; return(myServiceData); } } } catch (SqlException sqlEx) { myServiceData.Result = false; myServiceData.ErrorMessage = "Database failure"; myServiceData.ErrorDetails = sqlEx.ToString(); throw new FaultException <ServiceData>(myServiceData, sqlEx.ToString()); // A DEBUGGER EL FOGJA KAPNI EZT IS, LEÁLL HOGYHA VS-BŐL VAN INDÍTVA } catch (FieldAccessException fieldEx) { myServiceData.Result = false; myServiceData.ErrorMessage = "Please Log In"; myServiceData.ErrorDetails = fieldEx.ToString(); throw new FaultException <ServiceData>(myServiceData, fieldEx.ToString()); } catch (Exception e) { myServiceData.Result = false; myServiceData.ErrorDetails = e.ToString(); throw new FaultException <ServiceData>(myServiceData, e.ToString()); } }