Exemplo n.º 1
0
        public Service_Office CreateServiceOffice(string Description, string Municipality, string UserName)
        {
            var dbContext = new SDIIS_DatabaseEntities();
            int munId     = (from a in dbContext.Local_Municipalities
                             where a.Description == Municipality
                             select a.Local_Municipality_Id).FirstOrDefault();
            var service_Office = new Service_Office()
            {
                Description           = Description,
                Local_Municipality_Id = munId,

                Is_Active    = true,
                Is_Deleted   = false,
                Date_Created = DateTime.Now,
                Created_By   = UserName
            };

            try
            {
                var newService_Office = dbContext.Service_Offices.Add(service_Office);

                dbContext.SaveChanges();

                return(newService_Office);
            }
            catch (Exception)
            {
                return(null);
            }
        }
Exemplo n.º 2
0
        public void EditServiceOffice(Service_Office Obj, string userName)
        {
            var dbContext      = new SDIIS_DatabaseEntities();
            var ServiceOffice  = dbContext.Service_Offices.Find(Obj.Service_Office_Id);
            var service_Office = new Service_Office();


            service_Office.Description           = Obj.Description;
            service_Office.Local_Municipality_Id = Obj.Local_Municipality_Id;

            service_Office.Is_Active          = Obj.Is_Active;
            service_Office.Is_Deleted         = Obj.Is_Deleted;
            service_Office.Date_Last_Modified = DateTime.Now;
            service_Office.Modified_By        = userName;

            try
            {
                dbContext.SaveChanges();
            }
            catch (Exception)
            {
            }
        }