public IActionResult GetByID([FromBody] IdIntModel model) { if (model == null) { _logger.LogWarning($"ProfileTypeDefinitionController|GetByID|Invalid model (null)"); return(BadRequest($"Invalid model (null)")); } var result = this.GetItem(model.ID); if (result == null) { _logger.LogWarning($"ProfileTypeDefinitionController|GetById|No records found matching this ID: {model.ID}"); return(BadRequest($"No records found matching this ID: {model.ID}")); } //increment page visit count for this item var userToken = UserExtension.DalUserToken(User); var analytic = _dalAnalytics.Where(x => x.ProfileTypeDefinitionId == model.ID, userToken, null, null, false).Data.FirstOrDefault(); if (analytic == null) { _dalAnalytics.Add(new ProfileTypeDefinitionAnalyticModel() { ProfileTypeDefinitionId = model.ID, PageVisitCount = 1 }, userToken); } else { analytic.PageVisitCount += 1; _dalAnalytics.Update(analytic, null); } return(Ok(result)); }
static void Main(string[] args) { //1 //ручной вариант //IDal mssqldal = new MSSQLDal(); //IDal oracldal = new OracleDal(); //Customer obj = new Customer(mssqldal); //2 //framwork Unity //IUnityContainer objContainer = new UnityContainer(); //objContainer.RegisterType<Customer>(); //objContainer.RegisterType<IDal, MSSQLDal>(); //objContainer.RegisterType<IDal, OracleDal>(); //Customer obj = objContainer.Resolve<Customer>(); //3 myself ImyDIRepository objContainer = new DIContainer(); //objContainer.RegisterType<IDal, MSSQLDal>(); objContainer.RegisterType <IDal, OracleDal>(); IDal obj = objContainer.Resolver <IDal>(); // obj.Add("test1"); }
public void Add() { if (IsValid) { dal.Add(this); } }
private void btnAdd_Click(object sender, EventArgs e) { SetCustomer(); IDal <CustomerBase> dal = FactoryDalLayer <IDal <CustomerBase> > .Create(DalLayer.Text); dal.Add(cust); // In memory dal.Save(); // Physical committ LoadGrid(); ClearCustomer(); }
public async Task <IActionResult> Add([FromBody] ProfileModel model) { if (model == null) { _logger.LogWarning($"ProfileController|Add|Invalid model (null)"); return(BadRequest($"Invalid model (null). Check Publish Date formatting.")); } var userToken = UserExtension.DalUserToken(User); //test for unique namespace/owner id/publish date combo if (!IsValidModel(model, userToken)) { return(Ok(new ResultMessageWithDataModel() { IsSuccess = false, Message = "There is already a profile with this namespace and publish date combination. Enter a different namespace or publish date.", Data = null })); } //set some values server side model.AuthorId = userToken.UserId; model.NodeSetFiles = null; model.StandardProfileID = null; //re-validate ModelState.Clear(); TryValidateModel(model); if (!ModelState.IsValid) { var errors = ExtractModelStateErrors(); return(BadRequest("The profile record is invalid. Please correct the following: " + errors.ToString())); } var id = await _dal.Add(model, userToken); if (id < 0) { _logger.LogWarning($"ProfileController|Add|Could not add profile item."); return(BadRequest("Could not add profile item.")); } _logger.LogInformation($"ProfileController|Add|Added profile item. Id:{id}."); return(Ok(new ResultMessageWithDataModel() { IsSuccess = true, Message = "Item was added.", Data = id })); }
public void Add() { //if (true) //{ // Odal=new SQLServerDal(); //} //else //{ // Odal=new OracleDal(); //} Odal.Add(); }
public void Add() { //DAL // if(true) //config file, parameter table, etc.. // { // //Odal.Add(); //SQL Server // //Odal = new SQLServerDAL(); // } // else // { // Odal = new OracleDAL(); // //OdalOra.Add(); //Oracle // } _odal.Add(); }
public IActionResult NewPost(EditPostViewModel vm) { if (!ModelState.IsValid) { return(View(vm)); } Post p = new Post { Id = Guid.NewGuid().ToString(), CategoryId = vm.CategoryId, Category = _dal.CategoryById(vm.CategoryId), Content = vm.Content, IsPublished = false, PublishDate = DateTime.UtcNow, Slug = vm.Title.Conform(), Title = vm.Title, Order = _dal.GetOrderNumber(), Tags = vm.Tags }; _dal.Add(p); return(RedirectToAction(nameof(Index))); }
public void Add() { obj.Add(); }
public void Add() { _database.Add(); }
public void Add(string str) { //DAL Odal.Add(str); }
public void Add() { dal.Add(); }
/// <summary> /// Add or update a profile type def from the front end. This is different than importing a nodeset XML file. /// </summary> /// <param name="model"></param> /// <returns></returns> private async Task <IActionResult> UpdateInternal(ProfileTypeDefinitionModel model, bool isAdd) { var userToken = UserExtension.DalUserToken(User); //For front end, set Profile to null to ensure that the DAL does not see this as a changed object that must be updated. //Setting ProfileId will suffice. if (model.ProfileId.HasValue && model.ProfileId.Value > 0) { model.Profile = null; } if (isAdd) { model.ID = 0; //satisfy required field and set to 0 will indicate new item } //clean up stuff - set new ids to 0 rather than -1 for server side handling if (model.ProfileAttributes != null) { foreach (var attrib in model.ProfileAttributes) { if (attrib.TypeDefinitionId <= 0) { attrib.TypeDefinitionId = model.ID; } if (attrib.ID < 0) { attrib.ID = null; } if (attrib.CompositionId < 0) { attrib.CompositionId = null; } //if (attrib.CustomDataTypeId < 0) attrib.CustomDataTypeId = null; } //on front end, all attributes stored in single collection. // split out compositions, primitive attributes // into individual lists for DAL, DB. model.Attributes = model.ProfileAttributes.Where(a => (!a.CompositionId.HasValue || a.CompositionId < 0)).ToList(); // (!a.CustomDataTypeId.HasValue || a.CustomDataTypeId < 0)).ToList(); var comps = model.ProfileAttributes.Where(a => a.CompositionId.HasValue && a.CompositionId >= 0).ToList(); model.Compositions = _profileUtils.MapProfileAttributeToCompositionModels(comps); //var varTypes = model.ProfileAttributes.Where(a => a.CustomDataTypeId.HasValue && a.CustomDataTypeId >= 0).ToList(); //model.CustomDataTypes = _profileUtils.MapProfileAttributeToCustomDataTypeModels(varTypes); } //clear out stuff unrelated to the save of the item. There is lots of related stuff that we use in the display //that will trip up validation but is not central to the profile save operation. model.Ancestory = null; model.TypeId = model.Type.ID; //moved to DAL...set this to null to ensure that the DAL does not see this as a changed object that must be updated. Setting ProfileId will suffice. //model.Profile = null; //re-validate ModelState.Clear(); TryValidateModel(model); //required if (!model.ProfileId.HasValue) { ModelState.AddModelError("Profile", "Profile type definition must be assigned to a profile"); } if (!ModelState.IsValid) { var errors = ExtractModelStateErrors(); return(BadRequest("The item is invalid. Please correct the following: " + errors.ToString())); } int?id = 0; if (isAdd) { id = await _dal.Add(model, userToken); //increment extend count for this item's parent var analytic = _dalAnalytics.Where(x => x.ProfileTypeDefinitionId == model.Parent.ID, userToken, null, null, false).Data.FirstOrDefault(); if (analytic == null) { await _dalAnalytics.Add(new ProfileTypeDefinitionAnalyticModel() { ProfileTypeDefinitionId = model.Parent.ID.Value, ExtendCount = 1 }, userToken); } else { analytic.ExtendCount += 1; await _dalAnalytics.Update(analytic, null); } } else { id = await _dal.Update(model, userToken); } if (id < 0) { _logger.LogWarning($"ProfileTypeDefinitionController|UpdateInternal|Could not {(isAdd ? "add" : "update")} profile type definition."); return(BadRequest($"Could not {(isAdd ? "add" : "update")} profile type definition.")); } _logger.LogInformation($"ProfileTypeDefinitionController|UpdateInternal|{(isAdd ? "Added" : "Updated")} profile type definition. Id:{id}."); //return result object plus id. return(Ok(new ResultMessageWithDataModel() { IsSuccess = true, Message = $"Item was {(isAdd ? "added" : "updated")}.", //Data = new JRaw(JsonConvert.SerializeObject(this.GetItem(model.ID)) //Data = new JRaw(JsonConvert.SerializeObject(new IdIntModel() { ID = id })) Data = id })); }
public void Add() { _iobjDal.Add(); }
public void Add() { // dal Odal.Add(); }