Exemplo n.º 1
0
 /* Author: Wenyu Zhang*/
 public void createLLd_ATS(LLD_ATS ats)
 {
     using (var context = new MockERKSDb())
     {
         context.LLD_ATS.Add(ats);
         context.SaveChanges();
     }
 }
Exemplo n.º 2
0
 /* Author: Wenyu Zhang*/
 public void createLLD_PBL(LLD_PBL pbl)
 {
     using (var context = new MockERKSDb())
     {
         context.LLD_PBL.Add(pbl);
         context.SaveChanges();
     }
 }
Exemplo n.º 3
0
 /* Author: Wenyu Zhang*/
 public void createOperation(Operation oper)
 {
     using (var context = new MockERKSDb())
     {
         context.Operations.Add(oper);
         context.SaveChanges();
     }
 }
Exemplo n.º 4
0
 /* Author: Wenyu Zhang*/
 public void createLocation(Site_Address address)
 {
     using (var context = new MockERKSDb())
     {
         context.Site_Address.Add(address);
         context.SaveChanges();
     }
 }
Exemplo n.º 5
0
 public void File_Add(Site_File item, int id)
 {
     using (var context = new MockERKSDb())
     {
         item.Organization_ID = id;
         context.Site_File.Add(item);
         context.SaveChanges();
     }
 }
Exemplo n.º 6
0
 public void Officer_Add(Officer item)
 {
     using (var context = new MockERKSDb())
     {
         //any business rules
         context.Officers.Add(item);
         context.SaveChanges();
     }
 }
Exemplo n.º 7
0
        public void Client_Update(Organization item)
        {
            using (var context = new MockERKSDb())
            {
                context.Entry(item).State =
                    System.Data.Entity.EntityState.Modified;



                context.SaveChanges();
            }
        }
Exemplo n.º 8
0
        public void Officer_Update(Officer item)
        {
            using (var context = new MockERKSDb())
            {
                context.Entry(item).State =
                    System.Data.Entity.EntityState.Modified;



                context.SaveChanges();
            }
        }
Exemplo n.º 9
0
 /* Author: Wenyu Zhang */
 public void file_update(int fileID, int organizationId)
 {
     using (var context = new MockERKSDb())
     {
         Site_File file = (from x in context.Site_File
                           where x.File_ID == fileID
                           select x).FirstOrDefault();
         file.Organization_ID = organizationId;
         context.Site_File.Attach(file);
         context.Entry(file).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
Exemplo n.º 10
0
        public void File_Update(Site_File file)
        {
            using (var context = new MockERKSDb())
            {
                context.Site_File.Attach(file);

                file.File_Status = string.IsNullOrEmpty(file.File_Status) ? null : file.File_Status;

                context.Entry(file).State = System.Data.Entity.EntityState.Modified;

                context.SaveChanges();
            }
        }
Exemplo n.º 11
0
        public void RegisterOrganization(string organizationName, int description, string phone, string email, string userName)
        {
            using (var context = new MockERKSDb())
            {
                Organization newOrg = new Organization();
                newOrg.Organization_Name = organizationName;
                newOrg.Description_ID    = description;
                newOrg.Email             = email;
                newOrg.Phone             = phone;
                newOrg.User_Name         = userName;

                context.Organizations.Add(newOrg);

                context.SaveChanges();
            }
        }
Exemplo n.º 12
0
        public void Client_Delete(int organizationId)
        {
            using (var context = new MockERKSDb())
            {
                var existing = context.Organizations.Find(organizationId);

                if (existing == null)
                {
                    throw new Exception("Client/Organization does not exists on database.");
                }

                context.Organizations.Remove(existing);

                context.SaveChanges();
            }
        }
Exemplo n.º 13
0
        public void Officer_Delete(int Officerid)
        {
            using (var context = new MockERKSDb())
            {
                var existing = context.Officers.Find(Officerid);

                if (existing == null)
                {
                    throw new Exception("Officer does not exists on database.");
                }

                context.Officers.Remove(existing);

                context.SaveChanges();
            }
        }
Exemplo n.º 14
0
        public void DeleteFile(int fileID)
        {
            using (var context = new MockERKSDb())
            {
                //TODO: Find the file
                var file = context.Site_File.Find(fileID);
                if (file == null)
                {
                    throw new ArgumentException("This file doesn't exist");
                }

                //Getting rid of all the Foreign Key Associted with the class.
                bool categoryMatch = context.Categories.Any(x => x.Category_ID == file.Category_ID);
                if (!categoryMatch)
                {
                    throw new Exception("No Category exists");
                }
                else
                {
                    context.Categories.Remove(file.Category);
                }


                bool typeMatch = context.Document_Type.Any(x => x.Document_Type_ID == file.Document.Document_Type_ID);
                if (!typeMatch)
                {
                    throw new Exception("No Document Type Exists");
                }
                else
                {
                    context.Document_Type.Remove(file.Document.Document_Type);
                }


                bool operMatch = context.Operations.Any(x => x.Operation_ID == file.Operation_ID);
                if (!operMatch)
                {
                    throw new Exception("No Operation is associated with that message.");
                }
                else
                {
                    context.Operations.Remove(file.Operation);
                }


                bool orgMatch = context.Organizations.Any(x => x.Organization_ID == file.Organization_ID);
                if (!orgMatch)
                {
                    throw new Exception("No Organization is associated with that file.");
                }
                else
                {
                    context.Organizations.Remove(file.Organization);
                }

                bool addressMatch = context.LLD_PBL.Any(x => x.PBL_ID == file.PBL_ID);
                if (!addressMatch)
                {
                    throw new Exception("No Address has been found....");
                }
                else
                {
                    context.LLD_PBL.Remove(file.LLD_PBL);
                }

                bool filetypeMatch = context.File_Type.Any(x => x.Type_ID == file.Type_ID);
                if (!filetypeMatch)
                {
                    throw new Exception("No File Type has been found");
                }
                else
                {
                    context.File_Type.Remove(file.File_Type);
                }

                context.Security_Classification.Remove(file.Security_Classification);


                context.Site_File.Remove(file);


                context.SaveChanges();
            }
        }