private Result ParseXML(string content, TemplateDTO t) { var result = new Result(); var root = XElement.Parse(content); foreach (var xc in root.Descendants(t.Cidade)) { var c = new Cidade() { Habitantes = (int)xc.Element(t.HabitantesCidade), Nome = ((string)xc.Element(t.NomeCidade)).Trim() }; foreach (var xb in xc.Descendants(t.Bairro)) { c.Bairros.Add(new Bairro() { Habitantes = (int)xb.Element(t.HabitantesBairro), Nome = ((string)xb.Element(t.NomeBairro)).Trim() }); } result.Cidades.Add(c); } return(result); }
public void Update_Location_Test() { string templateName = "Location"; TemplateDTO template = TemplateDalContainer.GetATemplateById(3, templateName); Assert.AreEqual(3, template.LocationId, "Id is does not match with the records id"); Assert.AreEqual("A new Beginning?", template.Name, "Name does not match with the records name"); TemplateDTO templateDTO = new TemplateDTO { Name = "The Kitchen", Title = "A place to come to strength", Story = "Well how long did i pass out was it a week a month or maby even a year <br>" + "Would the food in the fridige still be good or should i search for something fresh", AreaId = 1, FotoUrl = "~/Images/Background" }; string testResult = TemplateDalLogic.UpdateTemplate(3, templateDTO, templateName); TemplateDTO templateUpdated = TemplateDalContainer.GetATemplateById(3, templateName); Assert.AreEqual("The Kitchen", templateUpdated.Name, "Name does not match with the records name"); Assert.AreEqual("Update succesfull", testResult, "Update failed"); }
public async Task <ActionResult <CreateTemplateResponse> > Post([FromRoute] string clientID, [FromBody] CreateTemplateRequest request) { CreateTemplateResponse response = new CreateTemplateResponse(); string responseMessage = $"CREATE_{clientID}_TEMPLATE_{request.Title}"; try { var dto = new TemplateDTO { ClientID = clientID, Title = request.Title, Description = request.Description, Page = request.Page, Content = request.Content }; var factory = Factory.Instance.GetTemplate(_configuration); await factory.Save(dto.Adapt()); response.StatusCode = "200"; response.Data = $"Template {request.Title} created with success"; return(Ok(response)); } catch (Exception ex) { response.StatusCode = "500"; response.Messages.Add(ResponseMessage.Create(ex, responseMessage)); return(StatusCode(500, response)); } }
public TemplateDTO Insert(InsertTemplateDTO dto, Guid userId) { var user = userService.GetById(userId); var template = new Template() { Name = dto.Name, PropertyCity = dto.PropertyCity, CityPropertyName = dto.CityPropertyName, CityPropertyHabitants = dto.CityPropertyHabitants, PropertyNeighborhood = dto.PropertyNeighborhood, NeighborhoodPropertyHabitants = dto.NeighborhoodPropertyHabitants, NeighborhoodPropertyName = dto.NeighborhoodPropertyName, User = user }; repository.Insert(template); repository.SaveChanges(); var templateDto = new TemplateDTO() { Id = template.Id.ToString(), Name = dto.Name, PropertyCity = dto.PropertyCity, CityPropertyName = dto.CityPropertyName, CityPropertyHabitants = dto.CityPropertyHabitants, PropertyNeighborhood = dto.PropertyNeighborhood, NeighborhoodPropertyHabitants = dto.NeighborhoodPropertyHabitants, NeighborhoodPropertyName = dto.NeighborhoodPropertyName, }; return(templateDto); }
public ServiceAccountDTO ConvertToDAO(IAccountSettings serviceAccount) { ServiceAccountDTO target = new ServiceAccountDTO(); GoogleSheetsAccountSettings currentAccount = (GoogleSheetsAccountSettings)serviceAccount; target.ServiceAccountId = currentAccount.ID; target.ServiceAccountName = currentAccount.Name; target.Source = Sources.GoogleSheets; target.MinUpdateTime = target.MinUpdateTime; target.AccountVersion = serviceAccount.AccountVersion; List <TokenDTO> tok = new List <TokenDTO>(); List <TemplateDTO> templ = new List <TemplateDTO>(); if (currentAccount.Tokens != null && currentAccount.Tokens.Count > 0) { foreach (GoogleSheetsAccountToken token in currentAccount.Tokens) { TokenDTO localtok = token.ConvertToDAO(token); tok.Add(localtok); } target.Tokens = tok.ToArray(); } if (currentAccount.Template != null && currentAccount.Template.Count > 0) { foreach (GoogleSheetsAccountTemplate template in currentAccount.Template) { TemplateDTO locTemlate = template.ConvertToDAO(template); templ.Add(locTemlate); } target.MappingTemplates = templ.ToArray(); } return(target); }
public string GetAfterRegister(string TemplateCode, UserInfo MyUserInfo) { string ReturnValue = ""; string TemplateBody = ""; string ParseValue = ""; TemplateDTO MyTemplateDTO = new TemplateDTO(); try { //Get Template Body from TemplateID //MyTemplateDTO = m_TemplateDbService.GetTemplateByTemplateCode(TemplateCode, MyUserInfo); TemplateBody = MyTemplateDTO.TemplateBody; //Parse Here FormatCompiler compiler = new FormatCompiler(); Generator generator = compiler.Compile(TemplateBody); string JSONString = string.Empty; JSONString = JsonConvert.SerializeObject(MyUserInfo); //var reportData = String.Format("{{ feeTypes: {0} }}", JSONString); var reportData = JSONString; JObject jsonData = JObject.Parse(reportData); ParseValue = generator.Render(jsonData); ReturnValue = ParseValue; return(ReturnValue); } catch (Exception exp) { throw; } }
//Create template public static int Create(TemplateDTO TemplateDTO) { if (TemplateDTO.Title == null || TemplateDTO.Title == "") { return(0); } try { var Template = new Template(); GlobalSettings.LoggedInClientId = TemplateDTO.ClientId; int PartnerId = ClientService.GetById(TemplateDTO.ClientId).PartnerId; GlobalSettings.LoggedInPartnerId = PartnerId; UnitOfWork uow = new UnitOfWork(); Template = Transform.TemplateToDomain(TemplateDTO); uow.TemplateRepo.Insert(Template); uow.SaveChanges(); TemplateDTO.Id = Template.Id; return(TemplateDTO.Id); } catch (Exception) { throw; } }
protected override async Task Context() { await base.Context(); _compound1 = new Compound(); _compound2 = new Compound(); _template1 = new LocalTemplate { Name = "Template1", Id = "Id1" }; _template2 = new LocalTemplate { Name = "Template2", Id = "Id2" }; _templates = new List <Template> { _template1, _template2 }; _templateDTO1 = new TemplateDTO(_template1); A.CallTo(() => _templateTaskQuery.AllTemplatesFor(TemplateType.Compound)).Returns(_templates); sut.SelectedTemplatesChanged(new[] { _templateDTO1, new TemplateDTO(_template2) }); A.CallTo(() => _templateTaskQuery.LoadTemplateAsync <Compound>(_template1)).Returns(_compound1); A.CallTo(() => _templateTaskQuery.LoadTemplateAsync <Compound>(_template2)).Returns(_compound2); A.CallTo(_dialogCreator).WithReturnType <ViewResult>().Returns(ViewResult.Yes); await sut.LoadFromTemplateAsync <Compound>(TemplateType.Compound); }
private Result ParseJSON(string content, TemplateDTO t) { var result = new Result(); IList <JProperty> jcidades = null; JObject o = JObject.Parse(content); jcidades = o.Descendants(). Where(tk => tk.Type == JTokenType.Property && ((JProperty)tk).Name == t.ListaCidades). Select(x => (JProperty)x).ToList(); var cidades = new List <Cidade>(); foreach (var jct in jcidades) { var jc = jct.Value.ToObject <JArray>()[0]; var c = new Cidade() { Habitantes = (int)jc[t.HabitantesCidade], Nome = (string)jc[t.NomeCidade] }; var jbairros = jc[t.ListaBairros].Select(x => (JObject)x).ToList(); foreach (var jb in jbairros) { c.Bairros.Add(new Bairro() { Habitantes = (int)jb[t.HabitantesBairro], Nome = (string)jb[t.NomeBairro] }); } result.Cidades.Add(c); } return(result); }
public string SaveTemplate(TemplateDTO dto) { if (Login()) { return(Put("Template/" + dto.TemplateGuid, dto)); } return(null); }
public void Xoa_NhanVien_getFinger(TemplateDTO _templateDTO) { List <SqlParameter> sqlParams = new List <SqlParameter> { new SqlParameter("@MaChamCong", _templateDTO.MaChamCong) }; base.Procedure("NHANVIEN_deleteFinger", sqlParams); }
public IHttpActionResult Put(TemplateDTO pTemplateDTO) { if (!TemplatesData.updateTemplate(pTemplateDTO)) { return(BadRequest()); } return(Ok()); }
public void Delete_FingerByMaChamCong(TemplateDTO _templateDTO) { List <SqlParameter> sqlParams = new List <SqlParameter> { new SqlParameter("@MaChamCong", _templateDTO.MaChamCong) }; base.Procedure("NHANVIEN_deleteFingerByMaChamCongNew", sqlParams); }
public async Task <TemplateDTO> UpdateTemplateOfUser(string userId, TemplateDTO updatedTemplate) { await DeleteTemplateOfUser(userId, updatedTemplate.Id); var toReturn = await AddTemplateForUser(userId, updatedTemplate); return(toReturn); }
public static Boolean DeleteTemplate(IAccountTemplate template) { Boolean succeed = false; TemplateDTO targetTemplate = template.ConvertToDAO(template); succeed = services.DeleteMapping(targetTemplate); return(succeed); }
public void Get_A_Single_Location() { TemplateDTO template = TemplateDalContainer.GetATemplateById(3, "Location"); Assert.AreEqual(3, template.LocationId, "Id is does not match with the records id"); Assert.AreEqual("The Kitchen", template.Name, "Name does not match with the records name"); Assert.AreEqual(1, template.AreaId, "Area id does not match with the records Area id"); }
public DataTable Select_TemplateByMaChamCongUpToDevice(TemplateDTO _templateDTO) { List <SqlParameter> sqlParams = new List <SqlParameter> { new SqlParameter("@MaChamCong", _templateDTO.MaChamCong) }; return(base.executeNonQuerya("NHANVIEN_selectTemplateUpToDevice", sqlParams)); }
public DataTable NhanVien_getTemplate(TemplateDTO _templateDTO) { List <SqlParameter> sqlParams = new List <SqlParameter> { new SqlParameter("@MaChamCong", _templateDTO.MaChamCong) }; return(base.executeNonQuerya("NHANVIEN_getTEMPLATE", sqlParams)); }
public IHttpActionResult Post(TemplateDTO templateDTO) { if (!TemplatesData.insertTemplate(templateDTO)) { return(BadRequest()); } return(Ok()); }
public void AddTemplate(TemplateDTO templateDto, string path) { var template = Mapper.Map <Template>(templateDto); _templateService.Insert(template); SaveChanges(); _manageStorage.UploadImage(path, templateDto.Image, template.TemplateID.ToString()); }
public ActionResult _DeleteTemplate(string id_template) { TemplateDTO templateDTO = new TemplateDTO(); if (templateProvider.deleteTemplate(id_template, Request.Cookies["user_id"].Value).Result) { return(RedirectToAction("Index", "Templates")); } return(new HttpStatusCodeResult(404, "Can't find that")); }
public static TemplateDTO TemplateToDTO(Template Template) { if (Template == null) { return(null); } Mapper.CreateMap <Template, TemplateDTO>(); TemplateDTO TemplateDTO = Mapper.Map <TemplateDTO>(Template); return(TemplateDTO); }
public static Template TemplateToDomain(TemplateDTO TemplateDTO) { if (TemplateDTO == null) { return(null); } Mapper.CreateMap <TemplateDTO, Template>(); Template Template = Mapper.Map <Template>(TemplateDTO); return(Template); }
public void SelectTemplate(TemplateDTO templateDTO) { if (templateDTO == null) { return; } var rowHandle = _gridViewBinder.RowHandleFor(templateDTO); gridView.FocusedRowHandle = rowHandle; gridView.SelectRow(rowHandle); }
public bool CanEdit(TemplateDTO template) { var databaseType = template.DatabaseType; //Remote templates cannot be edited, even by dev if (databaseType == TemplateDatabaseType.Remote) { return(false); } return(_startOptions.IsDeveloperMode || databaseType == TemplateDatabaseType.User); }
public void Them_Template(TemplateDTO _templateDTO) { List <SqlParameter> sqlParams = new List <SqlParameter> { new SqlParameter("@MaChamCong", _templateDTO.MaChamCong), new SqlParameter("@FingerID", _templateDTO.FingerID), new SqlParameter("@Flag", _templateDTO.Flag), new SqlParameter("@FingerTemplate", _templateDTO.FingerTemplate), new SqlParameter("@FingerVersion", _templateDTO.FingerVersion) }; base.Procedure("TEMPLATE_add", sqlParams); }
public void Delete_Location_Test() { string templateName = "Location"; TemplateDTO template = TemplateDalContainer.GetATemplateById(2, templateName); Assert.AreEqual(2, template.LocationId, "Id is does not match with the records id"); Assert.AreEqual("The Bed Room", template.Name, "Name does not match with the records name"); string deleteResult = TemplateDalContainer.DeleteTemplate(templateName, 2); Assert.AreEqual($"Delete of {templateName} was a succes", deleteResult, "Delete action failed"); }
public async Task <TemplateDTO> AddTemplateForUser(string userId, TemplateDTO templateToAdd) { var mapped = _mapper.Map <Template>(templateToAdd); mapped.Id = ObjectId.GenerateNewId().ToString(); var usersCollection = _db.GetCollection <User>("users"); var result = await Task.Run(() => usersCollection.Update( Query.EQ("_id", ObjectId.Parse(userId)), Update.PushWrapped("templates", mapped) )); return(_mapper.Map <TemplateDTO>(mapped)); }
public async Task <TemplateDTO> SaveAsync(TemplateDTO template) { try { var temp = Mapper.Map <TemplateEntity>(template); temp.LastModifiedUser = temp.CreatedBy; if (template.Id == 0) { temp.CreatedOn = DateTime.Now; _dbContext.Templates.Add(temp); if (template?.ReportItems?.Count > 0) { _rdbContext.ReportItems.Add(Mapper.Map <ReportItemEntity>(template?.ReportItems)); } if (template?.SortItems?.Count > 0) { _sdbContext.SortItems.Add(Mapper.Map <SortItemEntity>(template?.SortItems)); } if (template?.FilterItems?.Count > 0) { _fdbContext.FilterItems.Add(Mapper.Map <FilterItemEntity>(template?.FilterItems)); } } else { temp.LastModifiedDate = DateTime.Now; _dbContext.Templates.Update(temp); if (template?.ReportItems?.Count > 0) { _rdbContext.ReportItems.Update(Mapper.Map <ReportItemEntity>(template?.ReportItems)); } if (template?.SortItems?.Count > 0) { _sdbContext.SortItems.Update(Mapper.Map <SortItemEntity>(template?.SortItems)); } if (template?.FilterItems?.Count > 0) { _fdbContext.FilterItems.Update(Mapper.Map <FilterItemEntity>(template?.FilterItems)); } } _dbContext.SaveChanges(); return(await Task.Run(() => Mapper.Map <TemplateDTO>(temp))); } catch (Exception e) { throw e; } }
//Get template details by id public static TemplateDTO GetById(int Id) { try { UnitOfWork uow = new UnitOfWork(); Template Template = uow.TemplateRepo.GetById(Id); TemplateDTO TemplateDTO = Transform.TemplateToDTO(Template); return(TemplateDTO); } catch { throw; } }
public IAccountTemplate ConvertFromDAO(TemplateDTO template) { GoogleSheetsAccountTemplate targetTemplate = new GoogleSheetsAccountTemplate(); targetTemplate.TemplateId = template.TemplateId; targetTemplate.TemplateName = template.TemplateName; if (template.Mapping.Length > 0) { targetTemplate.Mapping = (from tok in template.Mapping where tok.Key == "Mapping" select tok.Value).SingleOrDefault(); } return targetTemplate; }
public TemplateDTO ConvertToDAO(IAccountTemplate template) { TemplateDTO target = new TemplateDTO(); GoogleSheetsAccountTemplate currentTemplate = (GoogleSheetsAccountTemplate)template; target.TemplateName = currentTemplate.TemplateName; target.TemplateId = currentTemplate.TemplateId; List<MappingForSerialization> mappingList = new List<MappingForSerialization>(); MappingForSerialization map = new MappingForSerialization(); map.Key = "Mapping"; map.Value = currentTemplate.Mapping; mappingList.Add(map); target.Mapping = mappingList.ToArray(); return target; }