Example #1
0
        public IHttpActionResult ResultInsert(string name = null, string surname = null, bool admin = false)
        {
            try
            {
                BLResources resources = new BLResources();
                var         resource  = resources.Insert(name, surname, admin);

                return(Ok(new ResourcesVM(resource)));
            }

            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
Example #2
0
        public IHttpActionResult GetAll_Coded()
        {
            try
            {
                //using (var dbContext = new RBSEntities())
                //{
                //    var resources = dbContext.resource_list();
                //    return Ok(resources.ToList());
                //};

                //ResourceManager BL = new ResourceManager();
                //List<Resource> result = BL.GetResources();
                //return Ok(result);


                //Dispose to close connection
                //dbContext.Dispose(); //not useful because using the using

                BLResources             mng      = new BLResources();
                IEnumerable <Resources> resource = mng.GetAll_Coded();

                List <ResourcesVM> resources_list = new List <ResourcesVM>();

                foreach (Resources es in resource)
                {
                    ResourcesVM rs = new ResourcesVM()
                    {
                        id_resource   = es.id_resource
                        , name        = es.name
                        , surname     = es.surname
                        , email       = es.email
                        , username    = es.username
                        , admin       = es.admin
                        , status      = es.status
                        , insert_date = es.insert_date
                        , update_date = es.update_date
                    };

                    resources_list.Add(rs);
                }
                return(Ok(resources_list));
            }

            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
Example #3
0
        public IHttpActionResult GetAll()
        {
            try
            {
                BLResources resource      = new BLResources();
                var         resource_list = resource.GetAll();

                ResourcesVM obj = new ResourcesVM();

                return(Ok(obj.CreateList(resource_list)));
            }

            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
Example #4
0
        public IHttpActionResult ResourceDetail(string name = null, string surname = null, string username = null, string email = null)
        {
            try
            {
                BLResources resource        = new BLResources();
                var         resource_detail = resource.GetDetail(name, surname, username, email);


                //Return a ResourceVM Object mapped from Resource
                return(Ok(new ResourcesVM(resource_detail)));
            }

            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
Example #5
0
        private List <DOADM_ResourceDetails> GetResources()
        {
            long?          TimeZone = currentUser.ADM_UserPreference.TimezoneLkup != null ? currentUser.ADM_UserPreference.TimezoneLkup : (long)DefaultTimeZone.CentralStandardTime;
            ExceptionTypes result;
            List <DOADM_ResourceDetails> lstDOADM_ResourceDetails;
            BLResources           objBLResources           = new BLResources();
            DOADM_ResourceDetails objDOADM_ResourceDetails = new DOADM_ResourceDetails();

            objDOADM_ResourceDetails.IsActive      = true;
            objDOADM_ResourceDetails.ConsiderDates = true;
            result = objBLResources.SearchResources(TimeZone, objDOADM_ResourceDetails, out lstDOADM_ResourceDetails, out string strErrorMessage);
            //check result for DB action
            if (result != (long)ExceptionTypes.Success)
            {
                BLCommon.LogError(currentUser.ADM_UserMasterId, MethodBase.GetCurrentMethod().Name, (long)ErrorModuleName.Home, (long)ExceptionTypes.Uncategorized, strErrorMessage, strErrorMessage);
            }
            return(lstDOADM_ResourceDetails);
        }
Example #6
0
 public IHttpActionResult ResourceDelete(string name = null, string surname = null, string username = null, string email = null)
 {
     try
     {
         BLResources resources = new BLResources();
         var         result    = resources.Delete(name, surname, username, email);
         //if (result > 0)
         //{
         //    return Ok(result);
         //}
         //else
         //{
         //    return NotFound();
         //}
         return(Ok("Resource deleted"));
     }
     catch (Exception ex)
     {
         return(InternalServerError(ex));
     }
 }