public async Task <ActionResult> UnLock(UserForCRUD userToUnLock)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    HttpResponseMessage response = await _accountService.UnLockUser(userToUnLock);

                    var responseData = response.Content.ReadAsStringAsync().Result;
                    if (response.IsSuccessStatusCode)
                    {
                        // UnLock User successfully
                        return(RedirectToAction("Index"));
                    }

                    // UnLock User failed
                    ResponseObj resObj = JsonConvert.DeserializeObject <ResponseObj>(responseData);

                    ModelState.Clear();
                    ModelState.AddModelError("", "Error in Unlocking User! Reason: " + resObj.Message);
                }
                else
                {
                    ModelState.Clear();
                    ModelState.AddModelError("", $"Error in Unlocking User on form!");
                }

                return(View(userToUnLock));
            }
            catch (Exception ex)
            {
                object cauThongBao = $"Error in UnLocking User!<br /> Reason: {ex.Message}";
                return(View("Error", cauThongBao));
            }
        }
        public HttpResponseMessage Get_Country()
        {
            HttpResponseMessage hrm = new HttpResponseMessage();
            ResponseObj         ro  = new ResponseObj();

            try
            {
                SqlParameter[] prm = new SqlParameter[]
                {
                    new SqlParameter("@TYPE", "GET_COUNTRY")
                };
                DataTable DT = new SQLHelper().ExecuteDataTable("SP_COUNTRY", prm, CommandType.StoredProcedure);
                if (DT.Rows.Count > 0)
                {
                    ro.Status    = 1;
                    ro.Message   = "Success";
                    ro.dataTable = DT;
                }
                hrm = new GenLib().RecvAPIData(ro);
                return(hrm);
            }
            catch (Exception ex) {
                hrm = new GenLib().WriteErrorLog(ex);
                return(hrm);
            }
        }
Example #3
0
        public async Task <object> UpdateAllUsers(Users data)
        {
            ResponseObj obj    = new ResponseObj();
            var         result = await user.Users.FindAsync(data.Uid);

            if (result != null)
            {
                result.UserName     = data.UserName;
                result.Age          = data.Age;
                result.City         = data.City;
                result.Country      = data.Country;
                result.Gender       = data.Gender;
                result.Role         = data.Role;
                result.State        = data.State;
                result.Address      = data.Address;
                result.ModifiedDate = DateTime.Now;
                user.SaveChanges();
                obj.result  = true;
                obj.Message = Messages.UpdateSuccess;
            }
            else
            {
                obj.result  = false;
                obj.Message = Messages.SomethingWentWrong;
            }

            return(obj);
        }
        public async Task <ActionResult> Register(Register register)
        {
            try
            {
                HttpResponseMessage response = await _accountService.Register(register);

                var responseData = response.Content.ReadAsStringAsync().Result;

                if (response.IsSuccessStatusCode)
                {
                    // Get registered User
                    LoggedInUser userRegisteredIn = JsonConvert.DeserializeObject <LoggedInUser>(responseData);

                    // Sign in
                    SignInCustomIdentity(userRegisteredIn);

                    return(RedirectToAction("Index", "Home"));
                }

                ResponseObj resObj = JsonConvert.DeserializeObject <ResponseObj>(responseData);

                ModelState.Clear();
                ModelState.AddModelError("", "Error in register User! Reason: " + resObj.Message);
                return(View(register));
            }
            catch (Exception ex)
            {
                object cauThongBao = $"Error in register new user!<br /> Reason: {ex.Message}";
                return(View("Error", cauThongBao));
            }
        }
        public HttpResponseMessage AllSearch()
        {
            HttpResponseMessage hrm = new HttpResponseMessage();
            ResponseObj         ro  = new ResponseObj();

            try
            {
                SqlParameter[] prm = new SqlParameter[]
                {
                    new SqlParameter("@TYPE", "ALL_SEARCH")
                };
                DataTable DT = new SQLHelper().ExecuteDataTable("SP_INFORMATION", prm, CommandType.StoredProcedure);
                if (DT.Rows.Count > 0)
                {
                    ro.Status    = 1;
                    ro.Message   = "SUCCESS";
                    ro.dataTable = DT;
                }
                hrm = new GenLib().RecvAPIData(ro);
                return(hrm);
            }
            catch (Exception ex) {
                hrm = new GenLib().WriteErrorLog(ex);
                return(hrm);
            }
        }
Example #6
0
        public async Task <object> AddProductDetails(Products jsondata, string image)
        {
            ResponseObj res = new ResponseObj();

            byte[]   fs  = File.ReadAllBytes(image);
            Products obj = new Products
            {
                ProductName   = jsondata.ProductName,
                ProductHeight = jsondata.ProductHeight,
                Productprice  = jsondata.Productprice,
                ProductWeight = jsondata.ProductWeight,
                Image         = fs,
                AvailbleQty   = jsondata.AvailbleQty
            };
            await Context.AddAsync(obj);

            var result = Context.SaveChanges();

            if (result == 1)
            {
                res.result  = true;
                res.Message = Messages.InsertSuccess;
            }
            else
            {
                res.result  = false;
                res.Message = Messages.SomethingWentWrong;
            }
            return(obj);
        }
Example #7
0
        public HttpResponseMessage GetCountry()
        {
            HttpResponseMessage hrm = new HttpResponseMessage();
            ResponseObj         ro  = new ResponseObj();

            try
            {
                SqlParameter[] prm = new SqlParameter[]
                {
                    new SqlParameter("@TYPE", "GET_COUNTRY"),
                };
                DataTable dt = new SQLHelper().ExecuteDataTable("[SP_LOCATION_NAME]", prm, CommandType.StoredProcedure);
                if (dt.Rows.Count > 0)
                {
                    ro.Status    = 1;
                    ro.Message   = "SUCCESS";
                    ro.dataTable = dt;
                }
                hrm = new GenLib().RecvAPIData(ro);
                return(hrm);
            }
            catch (Exception ex)
            {
                hrm = new GenLib().WriteErrorLog(ex);
                return(hrm);
            }
        }
Example #8
0
        public async Task <ActionResult> Edit(Product product)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    using (var client = new HttpClient())
                    {
                        client.BaseAddress = new Uri(SD.BaseUrl);

                        ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls12 |
                                                               SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;

                        client.DefaultRequestHeaders.Clear();

                        // Access token
                        string accessToken = "";
                        accessToken = _userSession.AccessToken;

                        // Edit Product
                        string requestParams = SD.BaseUrl + "api/products/" + product.Id.ToString();
                        var    request       = new HttpRequestMessage(HttpMethod.Put, requestParams);
                        request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
                        request.Content = new StringContent(JsonConvert.SerializeObject(product));
                        request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json");

                        HttpResponseMessage response = await client.SendAsync(request);

                        var responseData = response.Content.ReadAsStringAsync().Result;

                        if (response.IsSuccessStatusCode)
                        {
                            // Edit Product successfully
                            return(RedirectToAction("Index"));
                        }

                        // Edit Product failed
                        ResponseObj resObj = JsonConvert.DeserializeObject <ResponseObj>(responseData);

                        ModelState.Clear();
                        ModelState.AddModelError("", "Error in editing Product! Reason: " + resObj.Message);
                    }
                }

                // Get Brands and Types list
                object errObj = await GetBrands_And_Types_List(product.ProductBrandId, product.ProductTypeId);

                if (errObj != null)
                {
                    return(View("Error", errObj));
                }

                return(View(product));
            }
            catch (Exception ex)
            {
                object cauThongBao = $"Error in editing Product!<br /> Reason: {ex.Message}";
                return(View("Error", cauThongBao));
            }
        }
Example #9
0
        public async Task <object> UpdateProductDetils(Products jsondata, string image)
        {
            var result = await Context.Products.FindAsync(jsondata.PrdId);

            ResponseObj res = new ResponseObj();

            byte[] fs = File.ReadAllBytes(image);
            if (result != null)
            {
                result.ProductName   = jsondata.ProductName;
                result.ProductHeight = jsondata.ProductHeight;
                result.Productprice  = jsondata.Productprice;
                result.ProductWeight = jsondata.ProductWeight;
                result.Image         = fs;
                result.AvailbleQty   = jsondata.AvailbleQty;
            }
            var save = Context.SaveChanges();

            if (save == 1)
            {
                res.result  = true;
                res.Message = Messages.UpdateSuccess;
            }
            else
            {
                res.result  = false;
                res.Message = Messages.SomethingWentWrong;
            }
            return(res);
        }
Example #10
0
        public async Task <object> AddAllUsers(Users data)
        {
            ResponseObj obj      = new ResponseObj();
            Users       userdata = new Users()
            {
                UserName = data.UserName,
                Country  = data.Country,
                State    = data.State,
                Zip      = data.Zip,
                Age      = data.Age,
                Gender   = data.Gender,
                Role     = data.Role,
                Password = data.Password
            };
            await user.AddAsync(obj);

            var result = user.SaveChanges();

            if (result == 1)
            {
                obj.result  = true;
                obj.Message = Messages.InsertSuccess;
            }
            else
            {
                obj.result  = false;
                obj.Message = Messages.SomethingWentWrong;
            }

            return(obj);
        }
    private void getStatus()
    {
        byte[] data = new byte[1024];
        //string input, stringData;
        IPEndPoint ipep   = new IPEndPoint(IPAddress.Parse("192.168.0.151"), 234);
        Socket     server = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);

        Random Statreq = new Random();
        int    index   = Statreq.Next(0, 5);


        Statusobject stobj = new Statusobject
        {
            Request   = "GetControlStatus",
            RequestID = index.ToString(),
            Controls  = new Control[] { new Control()
                                        {
                                            ID = "37", StatusValue = "255"
                                        } },
            Version     = "1501603666",
            RequestedBy = "DefaultUser"
        };


        string output = JsonConvert.SerializeObject(stobj);

        data = Encoding.ASCII.GetBytes(output);
        server.SendTo(data, data.Length, SocketFlags.None, ipep);               //Send Request to Server
        EndPoint Remote = (EndPoint) new IPEndPoint(IPAddress.Any, 0);

        data = new byte[1024];

        int recv = server.ReceiveFrom(data, ref Remote);                        //Reseive Response from Server

        Response.InnerHtml = Server.HtmlEncode("Message received from {0}:" + Remote);

        string json = data.ToString();

        ResponseObj Deserial = JsonConvert.DeserializeObject <ResponseObj>(Encoding.ASCII.GetString(data, 0, recv));

        LinkCheck.InnerHtml = Server.HtmlEncode("\n This is output\t" + Deserial.Data.ControlStatus[0].StatusValue + "\n\nTIME" + DateTime.Now);

        var ha = Deserial.Data.ControlStatus[0].StatusValue;

        int StatuValueInt = Convert.ToInt32(ha);

        if (StatuValueInt > 0)
        {
            MasterBedroomStatus = 1;

            MasterBedRoomButton.BackColor = Color.White;
        }
        else
        {
            MasterBedroomStatus = 0;

            MasterBedRoomButton.BackColor = Color.LightGray;
        }
    }
        // GET: Account
        public async Task <ActionResult> Index(string search_Data, string sort_Data, int?page = 1)
        {
            ViewBag.UsersAct = "active";
            List <UserForCRUD> usersList = new List <UserForCRUD>();
            int totalItems = 0;
            int pageSize   = 5;
            int pageIndex  = (page ?? 1);

            try
            {
                HttpResponseMessage response = await _accountService.GetUsersList(search_Data, sort_Data, pageIndex, pageSize);

                var responseData = response.Content.ReadAsStringAsync().Result;

                if (!response.IsSuccessStatusCode)
                {
                    ResponseObj resObj = JsonConvert.DeserializeObject <ResponseObj>(responseData);

                    object cauThongBao = "Error in getting list of Users!<br /> Reason: " + resObj.Message;
                    return(View("Error", cauThongBao));
                }

                Pagination <UserForCRUD> pagination = JsonConvert.DeserializeObject <Pagination <UserForCRUD> >(responseData);
                if (pagination == null)
                {
                    object cauThongBao = $"There is no User in list! Pagination is null.";
                    return(View("Error", cauThongBao));
                }

                usersList  = pagination.Data.ToList <UserForCRUD>();
                totalItems = pagination.Count;

                // Paging
                var usersAsIPagedList = new StaticPagedList <UserForCRUD>(usersList, pageIndex, pageSize, totalItems);
                ViewBag.OnePageOfUsers = usersAsIPagedList;

                // Sort by list
                ViewBag.SortsList = new SelectList(
                    new List <SelectListItem>
                {
                    new SelectListItem {
                        Text = "&amp;#xf15d;", Value = "displaynameAsc"
                    },
                    new SelectListItem {
                        Text = "&#xf15d; User Name", Value = "usernameAsc"
                    },
                    new SelectListItem {
                        Text = "&#xf15e; User Name", Value = "usernameDesc"
                    },
                }, "Value", "Text");

                return(View(usersList));
            }
            catch (Exception ex)
            {
                object cauThongBao = $"Error in getting list of Users!<br /> Reason: {ex.Message}";
                return(View("Error", cauThongBao));
            }
        }
Example #13
0
        // GET: AdminProducts
        public async Task <ActionResult> Index(string search_Data, string sort = "Id", string sortdir = "ASC", int?page = 1)
        {
            ViewBag.ProductsAct = "active";

            List <Product> productsList = new List <Product>();
            int            pageSize     = 5;
            int            pageIndex    = (page ?? 1);

            try
            {
                if (sort == "ProductBrand.Name")
                {
                    sort = "brand";
                }
                else if (sort == "ProductType.Name")
                {
                    sort = "type";
                }
                else
                {
                    sort = sort.ToLower();
                }

                sortdir = sortdir.Substring(0, 1).ToUpper() + sortdir.Substring(1).ToLower();
                sort    = sort + sortdir;

                // Brand Id = -1, Type Id = -1 means that we do not find products by Brand Id, Type Id
                HttpResponseMessage response = await _productService.GetProductsList(search_Data, sort, pageIndex, pageSize, -1, -1);

                //Storing the response details recieved from web api
                var responseData = response.Content.ReadAsStringAsync().Result;

                if (!response.IsSuccessStatusCode)
                {
                    ResponseObj resObj = JsonConvert.DeserializeObject <ResponseObj>(responseData);

                    object cauThongBao = "Error in getting list of Products!<br /> Reason: " + resObj.Message;
                    return(View("Error", cauThongBao));
                }

                Pagination <Product> pagination = JsonConvert.DeserializeObject <Pagination <Product> >(responseData);
                if (pagination == null)
                {
                    object cauThongBao = $"There is no Product in list! Pagination is null.";
                    return(View("Error", cauThongBao));
                }

                productsList       = pagination.Data.ToList <Product>();
                ViewBag.TotalItems = pagination.Count;

                return(View(productsList));
            }
            catch (Exception ex)
            {
                object cauThongBao = $"Error in getting list of Products!<br /> Reason: {ex.Message}";
                return(View("Error", cauThongBao));
            }
        }
Example #14
0
        // GET: Products
        public async Task <ActionResult> Index(string search_Data, int?page = 1)
        {
            List <Product> productsList = new List <Product>();
            int            totalItems   = 0;
            int            pageSize     = 8;
            int            pageIndex    = (page ?? 1);

            try
            {
                // Brand Id = -1, Type Id = -1 means that we do not find products by Brand Id, Type Id
                HttpResponseMessage response = await _productService.GetProductsList(search_Data, "", pageIndex, pageSize, -1, -1);

                var responseData = response.Content.ReadAsStringAsync().Result;

                if (!response.IsSuccessStatusCode)
                {
                    ResponseObj resObj = JsonConvert.DeserializeObject <ResponseObj>(responseData);

                    object cauThongBao = "Error in getting list of Products!<br /> Reason: " + resObj.Message;
                    return(View("Error", cauThongBao));
                }

                Pagination <Product> pagination = JsonConvert.DeserializeObject <Pagination <Product> >(responseData);
                if (pagination == null)
                {
                    object cauThongBao = $"There is no Product in list! Pagination is null.";
                    return(View("Error", cauThongBao));
                }

                productsList = pagination.Data.ToList <Product>();
                totalItems   = pagination.Count;

                List <Photo> photosList = new List <Photo>();
                foreach (var item in pagination.Data)
                {
                    photosList.AddRange(item.Photos);
                }

                ViewBag.Url_Img_PlaceHolder = SD.BaseUrl + SD.Url_Pic_PlaceHolder;
                vm = new Products_PhotosViewModel
                {
                    Products = productsList,
                    Photos   = photosList
                };

                // Paging
                var productsAsIPagedList = new StaticPagedList <Product>(productsList, pageIndex, pageSize, totalItems);
                ViewBag.OnePageOfProducts = productsAsIPagedList;

                return(View(vm));
            }
            catch (Exception ex)
            {
                object cauThongBao = $"Lỗi truy cập dữ liệu.<br /> Lý do: {ex.Message}";
                return(View("Error", cauThongBao));
            }
        }
Example #15
0
        public async Task <ActionResult> Details(int?id)
        {
            if (id == null || id < 1)
            {
                return(RedirectToAction("Index", "Products"));
            }

            try
            {
                Product             productFromDb = new Product();
                HttpResponseMessage response      = await _productService.GetProduct(id);

                var responseData = response.Content.ReadAsStringAsync().Result;

                if (!response.IsSuccessStatusCode)
                {
                    ResponseObj resObj = JsonConvert.DeserializeObject <ResponseObj>(responseData);

                    object cauThongBao = "Error in finding Product to view Detail.<br /> Reason: " + resObj.Message;
                    return(View("Error", cauThongBao));
                }

                productFromDb = JsonConvert.DeserializeObject <Product>(responseData);
                if (productFromDb == null)
                {
                    object cauThongBao = $"Cannot find Product with Id (" + id.ToString() + ").";
                    return(View("Error", cauThongBao));
                }

                List <Photo> photosList = new List <Photo>();
                photosList.AddRange(productFromDb.Photos);

                ViewBag.Url_Img_PlaceHolder = SD.BaseUrl + SD.Url_Pic_PlaceHolder;

                // Get Brands list
                List <ProductBrand> brandsList = new List <ProductBrand>();
                HttpResponseMessage responseBr = await _productService.GetBrandsList();

                var resData_Brand = responseBr.Content.ReadAsStringAsync().Result;
                if (!responseBr.IsSuccessStatusCode)
                {
                    object cauThongBao = $"Error in getting list of Brands!<br /> Reason: {resData_Brand}";
                    return(View("Error", cauThongBao));
                }

                brandsList         = JsonConvert.DeserializeObject <List <ProductBrand> >(resData_Brand);
                ViewBag.BrandsList = brandsList;

                return(View(productFromDb));
            }
            catch (Exception ex)
            {
                object cauThongBao = $"Lỗi truy cập dữ liệu.<br /> Lý do: {ex.Message}";
                return(View("Error", cauThongBao));
            }
        }
Example #16
0
        public async Task OnPostAsync()
        {
            string urlString = _configuration.GetSection("AzureFunctionsUrl").Value;

            PicoYPlacaPrediction = await Services.UtilServices.PostPicoYPlacaService(PicoYPlacaInputs, urlString);

            if (PicoYPlacaPrediction.Code < 0)
            {
                //TODO: redirect to an error page
            }
        }
Example #17
0
        public void OnGet()
        {
            PicoYPlacaInputs = new PicoYPlacaInput()
            {
                LicensePlate = "ABC-123",
                Date         = "01/09/2020",
                Time         = "00:00"
            };

            PicoYPlacaPrediction = new ResponseObj(0, "Enter the Values");
        }
        public void Initialize()
        {
            MockGatewayService = new Mock <IGatewayService>();
            MockLoggingService = new Mock <ILoggingService>();

            var fileStream = File.OpenRead(Invariant($"{AppDomain.CurrentDomain.BaseDirectory}\\TestData\\AllStates.txt"));
            var gatewayServiceResponseObj = new ResponseObj();

            gatewayServiceResponseObj.ResponseStream = fileStream;

            MockGatewayService.Setup(x => x.GetStatesInfo()).Returns(gatewayServiceResponseObj);
            MockLoggingService.Setup(x => x.Log(It.IsAny <string>())).Verifiable();
        }
Example #19
0
        public async Task <JsonResult> MyAction(string id, [FromServices] INodeServices nodeServices)
        {
            var           queryStrings = Request.Query;
            string        config       = "pg://*****:*****@[email protected]:5432/postgres";
            DBConfigModel model        = new DBConfigModel()
            {
                type   = "pg",
                config = config,
                query  = string.Format("SELECT * FROM public.apisrepository {0}", (string.IsNullOrEmpty(id))? string.Empty:"where id = " + id)
            };

            ResponseObj result = await nodeServices.InvokeAsync <ResponseObj>("./NodeApp/db-config-main", "GET", model);

            return(Json(result));
        }
Example #20
0
        public HttpResponseMessage Insert(List <UserManagement> RequestData)
        {
            HttpResponseMessage hrm = new HttpResponseMessage();
            ResponseObj         ro  = new ResponseObj();

            try
            {
                if (RequestData.Count == 0)
                {
                    ro.Status  = 0;
                    ro.Message = "Pass Proper Data!!";
                }
                else
                {
                    SqlParameter[] prm = new SqlParameter[]
                    {
                        new SqlParameter("@TYPE", "INSERT"),
                        new SqlParameter("@FIRST_NAME", RequestData[0].FIRST_NAME),
                        new SqlParameter("@LAST_NAME", RequestData[0].LAST_NAME),
                        new SqlParameter("@EMAIL_ID", RequestData[0].EMAIL_ID),
                        new SqlParameter("@PHONE_NO", RequestData[0].PHONE_NO),
                        new SqlParameter("@ADDRESS_L1", RequestData[0].ADDRESS_L1),
                        new SqlParameter("@ADDRESS_L2", RequestData[0].ADDRESS_L2),
                        new SqlParameter("@CITY", RequestData[0].CITY),
                        new SqlParameter("@STATE", RequestData[0].STATE),
                        new SqlParameter("@COUNTRY", RequestData[0].COUNTRY)
                    };
                    string MSG = Convert.ToString(new SQLHelper().ExecuteScalar("SP_USER_LOGIN_INFORMATION", prm, CommandType.StoredProcedure));
                    if (MSG == "SUCCESSFULLY INSERT")
                    {
                        ro.Status  = 1;
                        ro.Message = "Data Insert Successfully";
                    }
                    else
                    {
                        ro.Status  = 0;
                        ro.Message = "Data not save!!";
                    }
                }
                hrm = new GenLib().RecvAPIData(ro);
                return(hrm);
            }
            catch (Exception ex)
            {
                hrm = new GenLib().WriteErrorLog(ex);
                return(hrm);
            }
        }
Example #21
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            try
            {
                using (var client = new HttpClient())
                {
                    client.BaseAddress = new Uri(SD.BaseUrl);

                    ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls12 |
                                                           SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;

                    client.DefaultRequestHeaders.Clear();

                    // Access token
                    string accessToken = "";
                    accessToken = _userSession.AccessToken;

                    // Delete Product
                    string requestParams = SD.BaseUrl + "api/products/" + id.ToString();
                    var    request       = new HttpRequestMessage(HttpMethod.Delete, requestParams);
                    request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);

                    HttpResponseMessage response = await client.SendAsync(request);

                    var responseData = response.Content.ReadAsStringAsync().Result;

                    if (response.IsSuccessStatusCode)
                    {
                        // Delete Product successfully
                        return(RedirectToAction("Index"));
                    }

                    // Delete Product failed
                    ResponseObj resObj = JsonConvert.DeserializeObject <ResponseObj>(responseData);

                    ModelState.Clear();
                    ModelState.AddModelError("", "Error in deleting Product! Reason: " + resObj.Message);
                }

                // Delete Product successfully
                return(View());
            }
            catch (Exception ex)
            {
                object cauThongBao = $"Error in deleting Product!<br /> Reason: {ex.Message}";
                return(View("Error", cauThongBao));
            }
        }
        public HttpResponseMessage SaveUser(List <Information_Model> RequestData)
        {
            HttpResponseMessage hrm = new HttpResponseMessage();
            ResponseObj         ro  = new ResponseObj();

            try
            {
                if (RequestData.Count == 0)
                {
                    ro.Status  = 0;
                    ro.Message = "pass proper data!!";
                }
                else
                {
                    SqlParameter[] prm = new SqlParameter[]
                    {
                        new SqlParameter("@TYPE", "INSERT"),
                        new SqlParameter("@NAME", RequestData[0].NAME),
                        new SqlParameter("@ADDRESS", RequestData[0].ADDRESS),
                        new SqlParameter("@EMAIL_ID", RequestData[0].EMAIL_ID),
                        new SqlParameter("@PHONE_NO", RequestData[0].PHONE_NO),
                        new SqlParameter("@CITY", RequestData[0].CITY),
                        new SqlParameter("@GENDER", RequestData[0].GENDER)
                    };
                    string MSG = Convert.ToString(new SQLHelper().ExecuteScalar("SP_INFORMATION", prm, CommandType.StoredProcedure));
                    if (MSG == "SUCCESSFYLL")
                    {
                        ro.Status  = 1;
                        ro.Message = "INSERT SUCCESSFULLY";
                    }
                    else
                    {
                        ro.Status  = 0;
                        ro.Message = "NO DATA INSERT";
                    }
                }
                hrm = new GenLib().RecvAPIData(ro);
                return(hrm);
            }
            catch (Exception ex)
            {
                hrm = new GenLib().WriteErrorLog(ex);
                return(hrm);
            }
        }
Example #23
0
        public async Task <object> AddorderDetails(string jsondata)
        {
            ResponseObj obj           = new ResponseObj();
            var         sqlParameters = new SqlParameter(StoredProcedureParams.Jsondata, jsondata);
            var         result        = await Context.DBStatus.FromSql(Constants.sp_AddOrderDetails, sqlParameters).AsNoTracking().FirstOrDefaultAsync();

            if (result.DBResult == 1)
            {
                obj.result  = true;
                obj.Message = Messages.InsertSuccess;
            }
            else
            {
                obj.result  = false;
                obj.Message = Messages.SomethingWentWrong;
            }
            return(obj);
        }
Example #24
0
        public async Task <object> DeleteUserData(int i)
        {
            ResponseObj obj    = new ResponseObj();
            var         result = await user.Users.FindAsync(i);

            if (result != null)
            {
                result.IsDelete = true;
                user.SaveChanges();
                obj.result  = true;
                obj.Message = Messages.DeleteSuccess;
            }
            else
            {
                obj.result  = false;
                obj.Message = Messages.SomethingWentWrong;
            }
            return(obj);
        }
Example #25
0
        static void GetConfig(bool isFirst)
        {
            string url = "http://ConfigServer/api/config/Config/Pro";

#if DEBUG
            url = "http://" + ConfigServer + "/api/config/Config/Dev";
#endif
            ConfigParam configParam = new ConfigParam
            {
                env   = ENV,
                group = GROUP
            };
            RequestParam requestParam = new RequestParam
            {
                method = "GetConfig",
                param  = configParam
            };
            string body = JsonConvert.SerializeObject(requestParam);
            try
            {
                string      resp        = Utils.PostHttp(url, body, "application/json");
                ResponseObj responseObj = JsonConvert.DeserializeObject <ResponseObj>(resp);

                foreach (ConfigItem item in responseObj.data)
                {
                    Environment.SetEnvironmentVariable(item.key, item.value);
                }

                DatabaseOperation.TYPE           = new DBManager();
                RedisManager.ConfigurationOption = REDIS;
                Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm") + "> " + "加载配置信息完成");
                if (isFirst)
                {
                    Subscribe();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(url);
                Console.WriteLine(e.StackTrace);
                Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm") + "> " + "加载配置信息失败");
            }
        }
Example #26
0
        public async Task <ActionResult> DeletePhoto(int selectedProductId, int selectedPhotoId)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    HttpResponseMessage response = await _photoService.DeletePhoto(selectedProductId, selectedPhotoId);

                    var responseData = response.Content.ReadAsStringAsync().Result;
                    if (!response.IsSuccessStatusCode)
                    {
                        ResponseObj resObj = JsonConvert.DeserializeObject <ResponseObj>(responseData);

                        object cauThongBao = "Error in Delete Photo!<br /> Reason: " + resObj.Message;
                        return(View("Error", cauThongBao));
                    }

                    // Delete Photo successfully
                }

                // Get Product from Database
                Product_PhotosViewModel vm = new Product_PhotosViewModel();

                Dictionary <string, object> result = new Dictionary <string, object>();
                result = await GetProductFromDB(selectedProductId, "DeletePhoto");

                if (result["ViewModel"] == null)
                {
                    return(View("Error", result["ErrObj"]));
                }
                else
                {
                    vm = result["ViewModel"] as Product_PhotosViewModel;
                }

                return(View("EditPhoto", vm));
            }
            catch (Exception ex)
            {
                object cauThongBao = $"Error in Delete Photo!<br /> Reason: {ex.Message}";
                return(View("Error", cauThongBao));
            }
        }
Example #27
0
        public ResponseObj Reader(StreamReader obj)
        {
            ResponseObj ret = new ResponseObj();

            ret.Groups    = new List <Group>();
            ret.Materials = new MaterialList();

            lstVertices        = new List <Vector3f>();
            lstNormalVertices  = new List <Vector3f>();
            lstTextureVertices = new List <Vector3f>();
            dataLine           = this.ReaderLine(obj);
            while (!obj.EndOfStream)
            {
                TypeLine tp = this.GetTypeLine(dataLine[0]);
                switch (tp)
                {
                case TypeLine.GROUP:
                    ret.Groups.Add(this.ReaderGroup(obj, true));
                    break;

                case TypeLine.VERTEX:
                case TypeLine.VERTEX_NORMAL:
                case TypeLine.VERTEX_TEXTURE:
                case TypeLine.FACE:
                    ret.Groups.Add(this.ReaderGroup(obj, false));
                    break;

                case TypeLine.OTHER:
                    ret.Materials.Add(this.ReaderMaterial(obj));
                    break;

                default:
                    dataLine = this.ReaderLine(obj);
                    break;
                }
            }

            lstVertices.Clear();
            lstNormalVertices.Clear();
            lstTextureVertices.Clear();

            return(ret);
        }
Example #28
0
        public ResponseObj <List <Users> > GetAllUser()
        {
            ResponseObj <List <Users> > responseObj = new ResponseObj <List <Users> >();

            try
            {
                var lang      = Request.Headers.GetValues("Accept-Language").First();
                var _userList = _userBs.GetAllUser();
                responseObj.Data      = _userList;
                responseObj.isSuccess = true;
                responseObj.Message   = lang == "En" ? "List of User" : "List of User - Ar";
            }
            catch (Exception ex)
            {
                responseObj.Message   = ex.Message;
                responseObj.isSuccess = false;
                _common.ExeceptionHandleWithMethodName(ex, "GetAllUser");
            }
            return(responseObj);
        }
Example #29
0
        public async Task <object> UpdateOrderStatus(Order data)
        {
            ResponseObj obj = new ResponseObj();

            var result = await Context.Order.Where(x => x.UserId == data.UserId).ToListAsync();

            if (result != null)
            {
                result.ForEach(x => x.OrderStatus = data.OrderStatus);
                Context.SaveChanges();
                obj.result  = true;
                obj.Message = Messages.InsertSuccess;
            }
            else
            {
                obj.result  = false;
                obj.Message = Messages.SomethingWentWrong;
            }
            return(obj);
        }
Example #30
0
        public async Task <object> DeleteProductDetails(Products jsondata)
        {
            ResponseObj obj    = new ResponseObj();
            var         result = await Context.Products.FindAsync(jsondata.PrdId);

            if (result != null)
            {
                result.IsDelete = true;
                Context.SaveChanges();
                obj.result  = true;
                obj.Message = Messages.DeleteSuccess;
            }
            else
            {
                obj.result  = false;
                obj.Message = Messages.SomethingWentWrong;
            }

            return(obj);
        }