internal void Add(Type base_type, CType cType) { IProvider provider = _Providers[base_type]; provider.Add(cType); provider.Ready(cType.Id); }
private static Response Post <T>(this IProvider provider, T model) where T : IModel { provider.Add(model); provider.Save(); return(new Response <T>(model)); }
public IActionResult createCustomer([FromBody] Customer customer) { if (!ModelState.IsValid) { _log4net.Info("No Customer has been returned"); return(BadRequest()); } try { bool result = _provider.Add(customer); if (result) { _log4net.Info("Customer has been successfully created"); CustomerCreationStatus cts = new CustomerCreationStatus(); cts.Message = "Customer and its account has been successfully created."; cts.CustomerId = customer.CustomerId; return(Ok(cts)); } else { return(new StatusCodeResult(409)); } } catch (Exception e) { _log4net.Error("Error occurred while calling post method" + e.Message); return(new StatusCodeResult(500)); } }
public static void ImportData <T>(Site site, IProvider <T> provider, string fileName, Stream zipStream, bool @override) where T : IPersistable { using (ZipFile zipFile = ZipFile.Read(zipStream)) { if (zipFile.ContainsEntry(fileName)) { using (MemoryStream ms = new MemoryStream()) { var entry = zipFile[fileName]; entry.Extract(ms); ms.Position = 0; var list = Deserialize <List <T> >(ms, null); foreach (var item in list) { item.Site = site; var o = provider.Get(item); if (o != null && @override) { provider.Update(item, o); } if (o == null) { provider.Add(item); } } } } } }
public virtual void Add(T item) { try { //clear the cache before add to avoid get NullObject from cache. ClearObjectCache(GetSite(item)); innerProvider.Add(item); } finally { ClearObjectCache(GetSite(item)); } }
public virtual ActionResult Create(Category model, string @return) { JsonResultData data = new JsonResultData(ViewData.ModelState); if (ModelState.IsValid) { data.RunWithTry((resultData) => { _provider.Add(model); resultData.RedirectUrl = @return; }); } return(Json(data)); }
public virtual ActionResult Create([Bind(Exclude = "Categories")] Blog model, string @return, int[] categories = null) { JsonResultData data = new JsonResultData(ViewData.ModelState); if (ModelState.IsValid) { data.RunWithTry((resultData) => { SetCategories(model, categories); _provider.Add(model); resultData.RedirectUrl = @return; }); } return(Json(data)); }
private void _LoadSoul(int type_id, long id, bool return_type) { MemberMap map = _Protocol.GetMemberMap(); Type type = map.GetInterface(type_id); IProvider provider = _QueryProvider(type); IGhost ghost = _BuildGhost(type, id, return_type); ghost.CallMethodEvent += new GhostMethodHandler(ghost, _ReturnValueQueue, _Protocol, _Requester).Run; ghost.AddEventEvent += new GhostEventMoveHandler(ghost, _Protocol, _Requester).Add; ghost.RemoveEventEvent += new GhostEventMoveHandler(ghost, _Protocol, _Requester).Remove; provider.Add(ghost); if (ghost.IsReturnType()) { _RegisterRelease(ghost); } }
public IActionResult createCustomer([FromBody] Customer customer) { if (customer == null) { return(NotFound()); } _cust.Add(customer); _log4net.Info("Customer has been successfully created"); var client = new HttpClient(); client.BaseAddress = new Uri("https://localhost:44369"); HttpResponseMessage response1 = client.PostAsJsonAsync("api/Account/createAccount", new { CustomerId = Convert.ToInt32(customer.CustomerId) }).Result; var result1 = response1.Content.ReadAsStringAsync().Result; AccountCreationStatus st = JsonConvert.DeserializeObject <AccountCreationStatus>(result1); CustomerCreationStatus cts = new CustomerCreationStatus(); cts.Message = "Customer and its account has been successfully created."; cts.CustomerId = customer.CustomerId; return(Ok(cts)); }
public IActionResult createCustomer([FromBody] Customer customer) { if (customer == null) { return(NotFound()); } bool a = _cust.Add(customer); if (a) { _log4net.Info("Customer has been successfully created"); CustomerCreationStatus cts = new CustomerCreationStatus(); cts.Message = "Customer and its account has been successfully created."; cts.CustomerId = customer.CustomerId; return(Ok(cts)); } else { return(BadRequest()); } }
public SearchModule(IProvider provider) { _values = provider.GetAll(); Get["/Search/{name?}"] = parameters => Negotiate .WithView("Search") .WithModel((string)parameters.name); Get["/GetByName/{name}/{resultType?}"] = Get["/GetByName/{name?}/"] = parameters => Negotiate .AsResponseType((string)parameters.resultType ?? ResponseType.JSON) .WithModel(_values.Search((string)parameters.name).ToArray()); Post["/AddModelData/{name}/{lastname}/{cedula}"] = Get["/AddModelData/{name}/{lastname}/{cedula}"] = parameters => Negotiate .WithModel(provider.Add(this.Bind <Model>())) .AsJSON(); }
public IActionResult createCustomer([FromBody] Customer customer) { if (customer == null) { _log4net.Warn("User has sent some invalid CustomerId"); return(NotFound()); } bool result = _provider.Add(customer); if (result) { _log4net.Info("Customer has been successfully created"); CustomerCreationStatus cts = new CustomerCreationStatus(); cts.Message = "Customer and its account has been successfully created."; cts.CustomerId = customer.CustomerId; return(Ok(cts)); } else { return(NotFound()); } }
public virtual void Add(T obj) { _provider.Add(obj); }
private void _Bind(IProvider provider) { provider.Add(_Online); provider.Ready(_Online.Id); }
public virtual void Add(T item) { ClearObjectCache(GetSite(item)); innerProvider.Add(item); }
private void _Bind(IProvider provider) { _Connect.ConnectedEvent += _Connect_ConnectedEvent; provider.Add(_Connect); provider.Ready(_Connect.Id); }
public static void Set(Type type, IProvider provider) { m_providers.Remove(type); m_providers.Add(type, provider); }
public virtual void Add(T item) { ClearObjectCache(item); innerRepository.Add(item); }
private void _Bind(IProvider provider) { provider.Add(_Online); provider.Ready(_Online.Id); }
private void _Bind(IProvider provider) { _Connect.ConnectedEvent += _Connect_ConnectedEvent; provider.Add(_Connect); provider.Ready(_Connect.Id); }
protected override void OnAddProvider(IProvider <Type, IProvider> providers) { TProvider provider = OnCreateProvider(); providers.Add(typeof(TProvider), provider); }