Ejemplo n.º 1
0
 public async Task <int> Update(MS_PIC entity)
 {
     Repo.Update(entity);
     return(await UnitOfWork.SaveChangesAsync());
 }
Ejemplo n.º 2
0
        public EditProfileOutputModel EditProfile(EditProfileInputModel data)
        {
            DateTime?today = DateTime.Now;

            User user = new User();

            user.FirstName          = data.FirstName;
            user.LastName           = data.LastName;
            user.ID                 = data.UserID;
            user.UserName           = data.UserName;
            user.PhoneNumber        = data.NoTelp;
            user.LastUpdateByUserID = data.UserID;
            user.LastUpdateDate     = today;

            UserRepository userRepo = new UserRepository(db);

            userRepo.Update(user, false);

            Company comp = new Company();

            comp.UserID      = data.UserID;
            comp.NPWP        = data.NPWP;
            comp.Website     = data.Website;
            comp.Alamat      = data.Alamat;
            comp.CompanyName = data.NamaPerusahaan;
            comp.Email       = data.EmailPerusahaan;
            comp.Note        = data.Catatan;
            comp.Kategory    = data.Kategori;


            CompanyRepository compRepo = new CompanyRepository(db);

            compRepo.Update(comp, false);

            ContactPerson cp = new ContactPerson();

            cp.Email  = data.EmailPIC;
            cp.Name   = data.FirstName + " " + data.LastName;
            cp.UserID = data.UserID;

            ContactPersonRepository cpRepo = new ContactPersonRepository(db);

            cpRepo.Update(cp, true);


            var query = (from u in db.User
                         join c in db.Company on u.ID equals c.UserID
                         where u.ID == data.UserID
                         select new EditProfileOutputModel()
            {
                EmailPerusahaan = c.Email,
                EmailPIC = u.UserName,
                Alamat = c.Alamat,
                Catatan = c.Note,
                FirstName = u.FirstName,
                LastName = u.LastName,
                NamaPerusahaan = c.CompanyName,
                NoTelp = u.PhoneNumber,
                NPWP = c.NPWP,
                PhotoUrl = u.PhotoUrl,
                UserID = u.ID,
                UserName = u.UserName,
                Website = c.Website,
                Kategori = c.Kategory
            });

            return(query.FirstOrDefault());
        }