public static Results CreateVKL(VKL vkl) { try { if (VKLExists(vkl.Name, vkl.Type)) { Common.LogError("Atempt to create a vkl that already exists.", "Vkm.CreateVKL", (int)Results.TamperingAttempt); return Results.AlreadyExists; } using (DataAccess da = new DataAccess ()) { vkl.Id = Convert.ToInt32(da.ExecuteSPForScalar("New_VKL", new SqlParameter[] { new SqlParameter("@langCode", vkl.LangCode), new SqlParameter("@name", vkl.Name), new SqlParameter("@userId", vkl.UserId), new SqlParameter("@type", (byte)vkl.Type), new SqlParameter("@visibility", (byte)vkl.Visibility) })); } vkl.Data.Save(VKLFilePath(vkl.Name, vkl.Type)); return Results.Ok; } catch (Exception ex) { Common.LogError("Error creating VKL: " + ex.Message, "VKM.CreateVKL", (int)Results.ResourceError); } return Results.SomeError; }
public static int Exists(string UserName) { try { using (DataAccess da = new DataAccess()) { int uId = Convert.ToInt32(da.ExecuteSPForScalar("UserExists", new SqlParameter[] { new SqlParameter { DbType = DbType.String, ParameterName = "@userName", Direction = ParameterDirection.Input, Value = UserName } })); if (uId > 0) return uId; else return 0; } } catch (SqlException sqlEx) { Common.LogError(sqlEx.Message, Common.GetMethodName(MethodBase.GetCurrentMethod()), sqlEx.Number); } catch (Exception otherEx) { Common.LogError(otherEx.Message, Common.GetMethodName(MethodBase.GetCurrentMethod())); } return (int)Results.SomeError; }