c# - Variable available to multiple projects -


i have asp.net application designed ui layer connecting service layer, connecting business layer , down data access layer.

the classes layers have constructors, accept userid (int). used logging, , things "lastupdateuser , createuser" storage.

i working across time zones, , in user table, have timezoneid. in ui level, stored within session state , can manipulate dates based on timezone.

i create method in service layer, "gettimezonebyuser" , pass userid, whcih goes down layers data access layer, , gets timezone info.

problem having in data transfer object, have logic, uses time based info:

public class persondto {     public int id { get; set; }     public string firstname { get; set; }     public string surname { get; set; }     public decimal grosssalary { get; set; }     public string email { get; set; }     public bool deleted { get; set; }     public list<personnonavailibilitydto> nonavailibility { get; set; }      public string fullname     {         { return string.format("{0} {1}", firstname, surname); }     }     public string availabletoday     {                 {             if (nonavailibility != null)             {                 var = nonavailibility.firstordefault(t => datetime.utcnow.date <= t.enddate && datetime.utcnow.date >= t.startdate);                 if (i != null) return i.nonavailibilitytype ;                 return "";             }             return "";         }     } 

what think need sort of class, that's accessable layers, has public timezoneid, , if it's null, go grab database via data accessor classes. need reference project in data accessors.

is ok reference projects in dto classes? they're meant lightweight. there 'state' can store timezone, accessable layers? last, , worst option pass zimezoneid userid - way on constructors. seems bad idea.

the problem lies within fact you're dto class contains business logic. move code layer operates on appropriate abstraction level , calculate "availabletoday" property value. dto object should plain data object.


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -