Exemplo n.º 1
0
 internal async static Task EditServiceTypeAsync(Models.ServiceType service)
 {
     using (ApplicationDbContext context = new ApplicationDbContext())
     {
         context.Entry(service).State = EntityState.Modified;
         await context.SaveChangesAsync();
     }
 }
Exemplo n.º 2
0
 internal static async Task CreateServiceTypeAsync(Models.ServiceType service)
 {
     using (ApplicationDbContext context = new ApplicationDbContext())
     {
         context.ServiceType.Add(service);
         await context.SaveChangesAsync();
     }
 }
Exemplo n.º 3
0
 /// <summary>
 ///  Create domain model from web model
 /// </summary>
 public static ServiceType CreateFrom(this Models.ServiceType source)
 {
     return(new ServiceType
     {
         ServiceTypeId = source.ServiceTypeId,
         ServiceTypeCode = source.ServiceTypeCode,
         ServiceTypeName = source.ServiceTypeName,
         ServiceTypeDescription = source.ServiceTypeDescription
     });
 }
Exemplo n.º 4
0
        public async Task <ActionResult> Edit(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Models.ServiceType serviceType = await _service.GetServiceType((Guid)id);

            if (serviceType == null)
            {
                return(HttpNotFound());
            }
            return(View(serviceType));
        }
Exemplo n.º 5
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            ServiceType = await db.ServiceTypes.FindAsync(id);

            if (ServiceType == null)
            {
                return(NotFound());
            }
            return(Page());
        }
Exemplo n.º 6
0
        private StatusCode internalInit(List <Models.Service> lstService, List <Models.ServiceType> lstType)
        {
            StatusCode retVal = StatusCode.SUCCEED_STATUS;

            //foreach (Data.CommonData.server_service_cdtblRow r in commonData.server_service_cdtbl.Rows)
            foreach (Models.Service service in lstService)
            {
                try
                {
                    Type               found_type     = null;
                    Assembly           found_assembly = null;
                    Models.ServiceType serviceType    = lstType.Where(st => st.id == service.service_type_id).FirstOrDefault();
                    string             assembly_name  = serviceType.assembly_name;
                    string             full_name      = serviceType.class_name;
                    if (string.IsNullOrEmpty(assembly_name) == false)
                    {
                        try
                        {
                            found_assembly = AppDomain.CurrentDomain.Load(assembly_name);
                        }
                        catch (Exception) { }
                    }
                    if (found_assembly == null)
                    {
                        foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
                        {
                            found_assembly = assembly;
                            found_type     = assembly.GetType(full_name);
                            if (found_type != null)
                            {
                                break;
                            }
                        }
                    }

                    IService svc = (IService)found_assembly.CreateInstance(full_name);
                    svc.Init(Config, Access.JsonAccess.Deserialize <Models.ParameterSet>(service.parameter), service);
                    ServiceManager.lstService.Add(svc);
                }
                catch (Exception ex)
                {
                    retVal = new CommonStatusCode(CommonStatusCode.SERVICE_LOAD_ERROR, new object[] { service.id }, ex, Config, ApplicationID);
                }
            }

            return(retVal);
        }
Exemplo n.º 7
0
        public async Task <ActionResult> Edit(Models.ServiceType serviceType)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    await _service.EditServiceType(serviceType);

                    return(RedirectToAction("Index"));
                }
                catch (Exception)
                {
                    throw;
                }
            }
            return(View(serviceType));
        }
Exemplo n.º 8
0
        public async Task <ActionResult> Create(Models.ServiceType serviceType)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    serviceType.Id = Guid.NewGuid();
                    await _service.CreateServiceType(serviceType);

                    return(RedirectToAction("Index"));
                }
                catch (Exception)
                {
                    throw;
                }
            }

            return(View(serviceType));
        }
Exemplo n.º 9
0
 public async Task EditServiceType(Models.ServiceType service)
 {
     await DomainLogic.ServiceType.ServiceType.EditServiceTypeAsync(service);
 }
Exemplo n.º 10
0
 public async Task CreateServiceType(Models.ServiceType service)
 {
     await DomainLogic.ServiceType.ServiceType.CreateServiceTypeAsync(service);
 }