Exemple #1
0
 public domain.Korisnik Update(domain.Korisnik domainObject)
 {
     using (model.LearnByPracticeDataContext context = CreateContext())
     {
         IQueryable <model.Korisnik> query = context.Korisniks.Where(p => p.ID == domainObject.Id);
         model.Korisnik modelObject        = query.Single();
         modelObject.Korisnichko_Ime = domainObject.Username;
         modelObject.Lozinka         = domainObject.PasswordOdNiza;
         modelObject.Ime             = domainObject.Ime;
         modelObject.Prezime         = domainObject.Prezime;
         modelObject.Pol             = ToModel(domainObject.Pol);
         modelObject.Organizacija_ID = domainObject.organizacija.Id;
         modelObject.Email           = domainObject.Email;
         modelObject.Telefonski_Broj = domainObject.Mobilen;
         modelObject.Mentor          = domainObject.Mentor;
         modelObject.Student         = domainObject.Student;
         if (modelObject.Student == true)
         {
             modelObject.Studiska_Programa_ID = domainObject.studiskaPrograma.Id;
         }
         else
         {
             modelObject.Studiska_Programa_ID = null;
         }
         modelObject.Administrator = domainObject.Administrator;
         context.SubmitChanges();
         domain.Korisnik result = ToDomain(modelObject);
         return(result);
     }
 }
Exemple #2
0
        private domain.Korisnik ToDomain(model.Korisnik modelObject)
        {
            domain.Korisnik domainObject = new domain.Korisnik();
            domainObject.Id                  = modelObject.ID;
            domainObject.Username            = modelObject.Korisnichko_Ime;
            domainObject.PasswordOdNiza      = modelObject.Lozinka.ToArray();
            domainObject.Ime                 = modelObject.Ime;
            domainObject.Prezime             = modelObject.Prezime;
            domainObject.Pol                 = ToDomain(modelObject.Pol);
            domainObject.studiskaPrograma.Id = modelObject.Studiska_Programa_ID.GetValueOrDefault();
            domainObject.organizacija.Id     = modelObject.Organizacija_ID;
            domainObject.Email               = modelObject.Email;
            domainObject.Mobilen             = modelObject.Telefonski_Broj;
            domainObject.Mentor              = modelObject.Mentor;
            domainObject.Student             = modelObject.Student;
            domainObject.Administrator       = modelObject.Administrator;

            return(domainObject);
        }