private static string GetParticular(string cuit, int empresa, string apellidoynombre, string dni) { var documento = CuitToDni(dni); var persona = ActiveRecordBase <PersonaDto> .TryFind(new KeyPersona(empresa, documento, TipoDocumento.DocumentoUnico)); var corporativo = ActiveRecordBase <PersonaDto> .TryFind(new KeyPersona(empresa, documento, TipoDocumento.Cuit)); if (persona == null && corporativo == null) { var tipoDoc = TipoDocumento.DocumentoUnico; var componentes = apellidoynombre.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries); var apellido = componentes.First(); var nombre = componentes.Last(); if (dni.Length > 9) { tipoDoc = TipoDocumento.Cuit; apellido = apellidoynombre; nombre = cuit; } CrearParticular(cuit, dni, apellido, nombre, empresa, tipoDoc); } return(documento); }
private static string GetCorporativo(string cuit, int empresa, string razon) { var documento = CuitToDni(cuit); var corporativo = ActiveRecordBase <PersonaDto> .TryFind(new KeyPersona(empresa, documento, TipoDocumento.Cuit)); if (corporativo == null) { CrearCorporativo(cuit, razon, empresa); } return(documento); }
private static CodigoPostalDto GetCp() { var cp = ActiveRecordBase <CodigoPostalDto> .TryFind("2000"); if (cp != null) { return(cp); } var cpDefault = new CodigoPostalDto("2000", "Rosario", "Santa Fe"); cpDefault.Save(); return(cpDefault); }
/// <summary> </summary> public static dynamic _copy_slow <t>(int id, String name) where t : new() { dynamic org; org = ActiveRecordBase <t> .TryFind(id); if (org == null) { return(org); } if (String.IsNullOrWhiteSpace(name)) { name = org.name + "_copy"; } dynamic copy = new t(); copy.name = name; ActiveRecordMediator <dynamic> .Save(copy); copy = (t)copy; int copy_id = copy.baseid; IValueInjecter injecter = new ValueInjecter(); injecter.Inject <CloneInjection>(copy, org); copy.name = name; copy.baseid = copy_id; //copy.owner.baseid = userService.getUserFull().baseid; copy.users.Clear(); copy.users.Add(userService.getUserFull()); copy.updated_date = DateTime.Now; //copy.status.id = 1; //copy = (dynamic)copy; try { ActiveRecordMediator <dynamic> .Save(copy); } catch { ActiveRecordMediator <dynamic> .Delete(copy); } return(copy); }
/// <summary> /// Returns null if no vote exists /// </summary> /// <param name="userId"></param> /// <param name="postId"></param> /// <returns></returns> public TVoteOnPost GetVote(int userId, int postId) { return(ActiveRecordBase <TVoteOnPost> .TryFind(new VoteKey(userId, postId))); }
/// <summary> </summary> public static dynamic make_revision <t>(int id, int version, int revision) where t : new() { dynamic org; org = ActiveRecordBase <t> .TryFind(id); if (org == null) { return(org); } int oldrevision = get_last_revision(org); dynamic copy = new t(); ActiveRecordMediator <dynamic> .Save(copy); copy = (t)copy; int copy_id = copy.baseid; IValueInjecter injecter = new ValueInjecter(); injecter.Inject <CloneInjection>(copy, org); if (revision > 0) { copy.revision = revision + 1; } else { copy.revision = oldrevision + 1; } if (version > 0) { copy.version = version; } copy.parent = org; copy.baseid = copy_id; String dest = ""; if (copy.loads_file) { //use the file ext to split.. fix it String[] fileparts = copy.static_file.Split('.'); if ( helperService.CalculateMD5Hash(file_handler.read_from_file(copy.static_file)) != helperService.CalculateMD5Hash(file_handler.read_from_file(fileparts[0] + "." + copy.version + "." + revision + "." + fileparts[1])) ) { dest = fileparts[0] + "." + copy.version + "." + copy.revision + "." + fileparts[1]; file_handler.copyfile(copy.static_file, dest); } } //copy.status.id = 1; //copy = (dynamic)copy; try { ActiveRecordMediator <dynamic> .Save(copy); return(copy); } catch { ActiveRecordMediator <dynamic> .Delete(copy); if (!String.IsNullOrWhiteSpace(dest)) { file_handler.deletefile(dest); } return(false); } }