示例#1
0
        public static void RemoveOrganization(Common.Organization organization)
        {
            Organization e = Mapper.CastOrganization(organization);

            using (dbRamotEntities db = new dbRamotEntities())
            {
                db.Organization.Remove(e);
                db.SaveChanges();
            }
        }
示例#2
0
 internal static Organization CastOrganization(Common.Organization organization)
 {
     return(organization == null ? null : new Organization()
     {
         Id = organization.Id,
         Name = organization.Name,
         Address = organization.Address,
         email = organization.email,
         Comments = organization.Comments,
         Contact = organization.Contact,
         Phone = organization.Phone
     });
 }
示例#3
0
        public static int AddOrganization(Common.Organization organization, Category[] categories)
        {
            int          x = 0;
            Organization e = Mapper.CastOrganization(organization);

            using (dbRamotEntities db = new dbRamotEntities())
            {
                foreach (var item in categories)
                {
                    var c = db.Categories.FirstOrDefault(ca => ca.Id == item.Id);
                    e.Categories.Add(c);
                }
                db.Organization.Add(e);
                db.SaveChanges();
                x = db.Organization.Local[0].Id;
            }
            return(x);
        }
示例#4
0
        public static int UpdateOrganization(Common.Organization organization, Category[] categories)
        {
            int          x = 0;
            Organization e = Mapper.CastOrganization(organization);

            using (dbRamotEntities db = new dbRamotEntities())
            {
                db.Organization.Find(organization.Id).Categories.Clear();
                foreach (var item in categories)
                {
                    var c = db.Categories.FirstOrDefault(ca => ca.Id == item.Id);
                    db.Organization.Find(organization.Id).Categories.Add(c);
                }
                db.Entry <Organization>(db.Set <Organization>().Find(e.Id)).CurrentValues.SetValues(e);
                db.SaveChanges();
                x = db.Organization.Local[0].Id;
            }
            return(x);
        }