public StringResponse Delete(string storeName, string identityId) { var response = new StringResponse { Success = false }; logger.Debug("Delete started"); Identity identity; if (Identity.TryParse(identityId, out identity) && identity != null) { if (this.storeService.Delete(storeName, identity)) { response.Response = "ok"; response.Success = true; response.NotJson = true; } else { response.StatusCode = 500; response.Response = "Could not delete row!"; } } else { response.StatusCode = 500; response.Response = "Could not interpret Id!"; } logger.Debug("Delete finished"); return response; }
private static BaseResponse SerializeResponse(HttpContext context, StringResponse stringResponse) { context.Response.Write(stringResponse.NotJson ? stringResponse.Response : new JavaScriptSerializer().Serialize(stringResponse.Response)); return stringResponse; }
public StringResponse Create(string storeName, Dictionary<string, string> values) { var response = new StringResponse { Success = false }; logger.Debug("Create started"); var newItem = this.storeService.Create(storeName, values); if (newItem != null) { response.Response = newItem.Id.ToString(); response.Success = true; response.NotJson = true; } else { response.StatusCode = 500; response.Response = "Could not create row!"; logger.Debug("Create failed - Could not create row!"); } logger.Debug("Create finished"); return response; }
public StringResponse Update(string storeName, int columnId, string value, string id, string columnName) { var response = new StringResponse { Success = false }; logger.DebugFormat("Update started"); Identity identity; if (Identity.TryParse(id, out identity) && identity != null) { if (this.storeService.UpdateCell(storeName, identity, columnId, columnName, value)) { response.Response = value; response.Success = true; } else { response.StatusCode = 500; response.Response = "Could not save cell!"; logger.Error("Update failed - Could not save cell!"); } } else { response.StatusCode = 500; response.Response = "Could not interpret Id!"; logger.Error("Update failed - Could not interpret Id!"); } logger.Debug("Update finished"); return response; }