private Gadget StoreMetadata(Gadget requestMetadata) { Logger.Write("Entered StoreMetadata"); //store in the DB DAGadget daGadget = DAGadget.Instance; if (daGadget.GetGadget(requestMetadata) == null) { return daGadget.AddGadget(requestMetadata); } else { return null; } }
public void UpdateGadgetMetadata(string owner, string gadgetName, string version, Gadget request) { //To Do - update code in the DB Logger.Write("Entered Update Gadget Metadata"); DAGadget daGadget = DAGadget.Instance; request.GadgetUri = string.Format(uriFormat, owner, gadgetName, version); if (daGadget.GetGadgetById(request.GadgetUri) != null) { daGadget.UpdateGadget(request); } else { WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.NotFound; WebOperationContext.Current.OutgoingResponse.StatusDescription = string.Format("Cannont Update! Gadget with Owner:{0} Name:{1} Version:{2} does not exist", owner, gadgetName, version); //WebOperationContext.Current.OutgoingResponse.SuppressEntityBody = true; Logger.Write("Exit Store Gadget with fail"); } }
public GadgetResponseBody CreateGadgetEntryPoint(Gadget request) { Logger.Write("Entered Create Gadget Entry Point"); if (request.hasCompuloryFieldsSet()) { Gadget resp = StoreMetadata(request); if (resp != null) { return new GadgetResponseBody { ServiceGadgetUri = baseServiceUri + resp.GadgetUri, GadgetLocationURL = baseServiceURL + resp.GadgetUri, GadgetMetadataUri = baseServiceUri + resp.GadgetUri + "/metadata", GadgetDataUri = baseServiceUri + resp.GadgetUri + "/data" }; } else { WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.Conflict; WebOperationContext.Current.OutgoingResponse.StatusDescription = "A Gadget with metadata this metadata already exists.Use PUT for Update or change Metadata"; //WebOperationContext.Current.OutgoingResponse.SuppressEntityBody = true; Logger.Write("Exit Store Gadget with fail"); return null; } } else { WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.BadRequest; WebOperationContext.Current.OutgoingResponse.StatusDescription = "One of Metadata compulsory fields is missing."; //WebOperationContext.Current.OutgoingResponse.SuppressEntityBody = true; Logger.Write("Exit Create Gadget Entry Point with fail"); return null; } }
partial void DeleteGadget(Gadget instance);
partial void UpdateGadget(Gadget instance);
partial void InsertGadget(Gadget instance);