public void AddNewMessages(MessagesFromBulidingModel messageModel)
        {
            AccessControlSystemEntities context   = new AccessControlSystemEntities();
            MessageFromBuilding         messageDB = new MessageFromBuilding();

            messageDB.Subject = messageModel.Subject;
            messageDB.Value   = messageModel.Text;
            context.MessageFromBuildings.Add(messageDB);
            context.SaveChanges();
            foreach (var item in messageModel.Companies)
            {
                MessagesOfCompany newDBItem = new MessagesOfCompany();
                newDBItem.CompanyId             = item.Id;
                newDBItem.MessageFromBuildingId = messageDB.Id;
                context.MessagesOfCompanies.Add(newDBItem);
            }
            context.SaveChanges();
        }
 public void DeleteUser(int UserId)
 {
     try
     {
         AccessControlSystemEntities context = new AccessControlSystemEntities();
         User userDB = context.Users.Where(x => x.Id == UserId).FirstOrDefault();
         context.Users.Remove(userDB);
         context.SaveChanges();
     }
     catch (Exception e)
     {
         throw new Exception(e.Message);
     }
 }
        public void DeleteCompany(int companyId)
        {
            AccessControlSystemEntities context = new AccessControlSystemEntities();

            try
            {
                Company companyDB = context.Companies.Where(x => x.Id == companyId).FirstOrDefault();
                context.Companies.Remove(companyDB);
                context.SaveChanges();
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
        }
Beispiel #4
0
        public void AddNewMessage(MessageFromCompanyModel messageModel)
        {
            AccessControlSystemEntities context = new AccessControlSystemEntities();

            try
            {
                MessageFromCompany messageDB = MaptoMessageFromCompanyDBModel(messageModel, context);
                context.MessageFromCompanies.Add(messageDB);
                context.SaveChanges();
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
        }
        public void AddNewEntryToDataBase(int memberId)
        {
            AccessControlSystemEntities context = new AccessControlSystemEntities();

            try
            {
                Entry entry = new Entry();
                entry.MemberId = memberId;
                entry.Time     = DateTime.Now;
                context.Entries.Add(entry);
                context.SaveChanges();
            }
            catch (Exception e)
            {
            }
        }
 public void AddNewUser(UserModel model)
 {
     try
     {
         AccessControlSystemEntities context = new AccessControlSystemEntities();
         User userDB = new User();
         userDB.Name     = model.Name;
         userDB.Password = model.Password;
         userDB.Role     = model.Role;
         context.Users.Add(userDB);
         context.SaveChanges();
     }
     catch (Exception e)
     {
         throw new Exception(e.Message);
     }
 }
        public void AddNewCompany(CompanyModel company)
        {
            AccessControlSystemEntities context = new AccessControlSystemEntities();

            try
            {
                Company companyDB = new Company();
                companyDB.Name    = company.Name;
                companyDB.Address = company.Address;
                companyDB.Phone   = company.Phone;
                context.Companies.Add(companyDB);
                context.SaveChanges();
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
        }
Beispiel #8
0
        public void AddNewMember(MemberModel model)
        {
            AccessControlSystemEntities context = new AccessControlSystemEntities();

            try
            {
                Member memberDB = new Member();
                memberDB.CardNumber = model.CardNumber;
                memberDB.FirstName  = model.FirstName;
                memberDB.LastName   = model.LastName;
                memberDB.Title      = model.Title;
                memberDB.CompanyId  = model.CompanyId;
                context.Members.Add(memberDB);
                context.SaveChanges();
            }
            catch (Exception e)
            {
            }
        }
Beispiel #9
0
        public void EditMember(MemberModel model)
        {
            AccessControlSystemEntities context = new AccessControlSystemEntities();

            try
            {
                Member memberDB = context.Members.Where(x => x.Id == model.Id).FirstOrDefault();
                if (memberDB != null)
                {
                    memberDB.CardNumber = model.CardNumber;
                    memberDB.FirstName  = model.FirstName;
                    memberDB.LastName   = model.LastName;
                    memberDB.Title      = model.Title;
                }
                context.SaveChanges();
            }
            catch (Exception e)
            {
            }
        }
Beispiel #10
0
        public void EditCompany(CompanyModel model)
        {
            AccessControlSystemEntities context = new AccessControlSystemEntities();

            try
            {
                Company companyDB = context.Companies.Where(x => x.Id == model.Id).FirstOrDefault();
                if (companyDB != null)
                {
                    companyDB.Id      = model.Id;
                    companyDB.Address = model.Address;
                    companyDB.Name    = model.Name;
                    companyDB.Phone   = model.Phone;
                }
                context.SaveChanges();
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
        }