Ejemplo n.º 1
0
        public bool InsertOrderData(CarInfoOrder carInfoOrder, string user_id)
        {
            try
            {
                CommanDB          procConn = new CommanDB();
                OracleParameter[] param    =
                {
                    new OracleParameter("@ac_order_identity", carInfoOrder.OrderIdentity),
                    new OracleParameter("@ac_user_id",        user_id),
                    new OracleParameter("@ac_car_id",         carInfoOrder.carId),
                    new OracleParameter("@ac_city_id",        carInfoOrder.cityId),
                    new OracleParameter("@ac_orderType",      carInfoOrder.orderType),
                    new OracleParameter("@ac_locationX",      carInfoOrder.locationX),
                    new OracleParameter("@ac_locationY",      carInfoOrder.locationY),
                    new OracleParameter("@ac_note",           carInfoOrder.note),
                };

                procConn.RunProc("insertOrder_sp", param);
                return(true);
            }
            catch (Exception ex)
            {
                throw new InsertException(language, ex.Message + "  INSERT Order DATA");
            }
        }
Ejemplo n.º 2
0
        public bool UpdateAccidentData(CarInfoOrder carInfoOrder)
        {
            try
            {
                CommanDB          procConn = new CommanDB();
                OracleParameter[] param    =
                {
                    new OracleParameter("@c_accident_id", carInfoOrder.order_id),
                    new OracleParameter("@ac_fixType",    carInfoOrder.orderType),
                    new OracleParameter("@ac_locationX",  carInfoOrder.locationX),
                    new OracleParameter("@ac_locationY",  carInfoOrder.locationY),
                };

                procConn.RunProc("updateInfoAndAccidentData_sp", param);
                return(true);
            }
            catch (Exception ex)
            {
                throw new UpdateException(language, ex.Message);
            }
        }
Ejemplo n.º 3
0
        public Response StoreOrderData(CarInfoOrder carInfoOrder, string user_id)
        {
            try
            {
                // Insert Order Data To DB
                if (new OrderRepository.OrderRepository(language).InsertOrderData(carInfoOrder, user_id))
                {
                    int order_id = new OrderRepository.OrderRepository(language).GetOrderIdByUserId(Convert.ToInt32(user_id));

                    // Insert order_details_assigns
                    foreach (int assign in carInfoOrder.orderDetailsIds)
                    {
                        new OrderRepository.OrderRepository(language).InsertOrderDetailAssign(order_id, assign);
                    }

                    //----------------------------



                    bool      imageStatus    = true;
                    Exception imageException = new Exception();



                    // Store Images
                    int i = 0;
                    foreach (string image in carInfoOrder.images)
                    {
                        string url = "";
                        i++;
                        string ImageName = "images/OrderImages/" + i + "_" + carInfoOrder.OrderIdentity + "_" + DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss") + ".png";



                        url = new UploadRepository(language).StoreImage(image, ImageName);

                        if (url != "")
                        {
                            try
                            {
                                new OrderRepository.OrderRepository(language).InsertOrderPictureUrl(ImageName, 1, order_id);
                            }
                            catch (InsertException ex)
                            {
                                imageStatus    = false;
                                imageException = ex;
                            }
                        }
                    }

                    //----------------



                    // check If Image Was Inserted And Response with This Data
                    if (imageStatus)
                    {
                        return(new Response(imageStatus, Messages.GetMessage(language, TypeM.ACCIDENT, orderM.IMAGE_Order_STORE), order_id));
                    }
                    else
                    {
                        return(new Response(imageStatus, Messages.GetMessage(language, TypeM.ACCIDENT, orderM.IMAGE_Order_ERROR), imageException, order_id));
                    }
                    ///-------------------------
                }
                else
                {
                    throw new InsertException(language);
                }
            }
            catch (EmptyViewException EmptyViewException)
            {
                return(new Response(false, EmptyViewException.RespMessage, EmptyViewException.ErrorMessage));
            }
            catch (InsertException InsertException)
            {
                return(new Response(false, InsertException.RespMessage, InsertException.ErrorMessage));
            }
            catch (UpdateException UpdateException)
            {
                return(new Response(false, UpdateException.RespMessage, UpdateException.ErrorMessage));
            }
            catch (Exception ex)
            {
                var st = new StackTrace(ex, true);
                // Get the top stack frame
                var frame = st.GetFrame(0);
                // Get the line number from the stack frame
                var line = frame.GetFileLineNumber();
                return(new Response(false, Messages.GetMessage(language, TypeM.DEFAULT, defaultM.UNEXPERROR) + ex.Message.ToString(), ex.Message.ToString() + "::: line NO:: " + line));
            }
        }
Ejemplo n.º 4
0
        public Response UpdateAccidentData(CarInfoOrder carInfoOrder)
        {
            try
            {
                //Prepare date


                if (new OrderRepository.OrderRepository(language).UpdateAccidentData(carInfoOrder))
                {
                    int  accidentId  = carInfoOrder.order_id;
                    bool imageStatus = true;

                    try
                    {
                        RequestCriteria requestCriteria = new RequestCriteria();
                        requestCriteria.accident_id = accidentId;
                        requestCriteria.city_id     = (int)carInfoOrder.cityId;
                        new OfferService.OfferService(language).insertOrUpdatePermission(requestCriteria);
                    }
                    catch (UpdateException)
                    {
                        throw new UpdateException(language);
                    }



                    // Store Images
                    int i = 0;
                    foreach (string image in carInfoOrder.images)
                    {
                        string url = "";
                        i++;
                        string ImageName = "images/OrderImages/" + i + "_" + accidentId + "_" + DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss") + ".png";

                        url = new UploadRepository(language).StoreImage(image, ImageName);
                    }

                    if (imageStatus)
                    {
                        return(new Response(imageStatus, Messages.GetMessage(language, TypeM.ACCIDENT, orderM.IMAGE_Order_ERROR)));
                    }
                    else
                    {
                        return(new Response(imageStatus, Messages.GetMessage(language, TypeM.ACCIDENT, orderM.IMAGE_Order_ERROR)));
                    }
                }
                else
                {
                    throw new InsertException(language);
                }
            }
            catch (EmptyViewException EmptyViewException)
            {
                return(new Response(false, EmptyViewException.RespMessage, EmptyViewException.ErrorMessage));
            }
            catch (InsertException InsertException)
            {
                return(new Response(false, InsertException.RespMessage, InsertException.ErrorMessage));
            }
            catch (Exception ex)
            {
                return(new Response(false, Messages.GetMessage(language, TypeM.DEFAULT, defaultM.UNEXPERROR), ex.Message.ToString()));
            }
        }
Ejemplo n.º 5
0
        public ActionResult <Response> StoreOrderDataAsync([FromQuery(Name = "lang")] string lang, [FromForm] string accessToken, [FromForm] string carId,
                                                           [FromForm] string orderType, [FromForm] string cityId, [FromForm] string locationX, [FromForm] string locationY, [FromForm] string orderDetailsIds, [FromForm] string note, [FromForm] string images)
        {
            List <string> imgs           = new List <string>();
            List <int>    orderassignIds = new List <int>();

            // Check If List Is NULL
            if (images != null)
            {
                imgs = JsonConvert.DeserializeObject <List <string> >(images);
            }

            ////NO car Service
            //if (carId == null)
            //    carId = "-1";


            // Check If List Is NULL
            if (orderDetailsIds != null)
            {
                orderassignIds = JsonConvert.DeserializeObject <List <int> >(orderDetailsIds);
            }



            // MAPPING DATA
            CarInfoOrder carInfoOrder = new CarInfoOrder();

            carInfoOrder.accessToken = accessToken;


            if (carId != null && carId != "" && carId != "0")
            {
                carInfoOrder.carId = Convert.ToInt32(carId);
            }
            else
            {
                carInfoOrder.carId = null;
            }


            if (cityId != null && cityId != "" && cityId != "0" && cityId != "-1")
            {
                carInfoOrder.cityId = Convert.ToInt32(cityId);
            }

            else
            {
                carInfoOrder.cityId = 1;
            }


            if (orderType != null)
            {
                carInfoOrder.orderType = Convert.ToInt32(orderType);
            }
            else
            {
                carInfoOrder.orderType = 1;
            }

            carInfoOrder.locationX = Convert.ToDouble(locationX);
            carInfoOrder.locationY = Convert.ToDouble(locationY);

            if (orderassignIds == null)
            {
                carInfoOrder.orderDetailsIds = new List <int>();
            }
            else
            {
                carInfoOrder.orderDetailsIds = orderassignIds;
            }

            carInfoOrder.note = note;

            if (imgs == null)
            {
                carInfoOrder.images = new List <string>();
            }
            else
            {
                carInfoOrder.images = imgs;
            }



            //check AccessToken
            string user_id = new UserService(lang).CheckAccessTokenUser(carInfoOrder.accessToken);

            carInfoOrder.OrderIdentity = new HelperRepository().generateIds((int)Enums.CreationNumberCode.order, DateTime.Now);

            if (user_id != null)
            {
                // STORE ACCIDENT DATA
                Response res      = new OrderService(lang).StoreOrderData(carInfoOrder, user_id);
                var      order_id = res.innerData;
                res.innerData = new  object();


                //Send Notification To ALL Admin When New Request Created
                if (res.status)
                {
                    try
                    {
                        //Get All Suppliers Ids
                        List <int> users = new UserRepository.UserRepository(lang).GetAllAdminIds();
                        foreach (int user in users)
                        {
                            try
                            {
                                new ServicesRepository(lang).SendNotiAllDevices(user, Messages.GetMessage(lang, TypeM.notifyM, notifyM.NOTI_TITLE),
                                                                                Messages.GetMessage(lang, TypeM.notifyM, notifyM.NOTI_NEW_ORDER), 1);
                            }
                            catch
                            {
                                ;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        new Response(false, ex.Message, ex.Message);
                    }
                }


                // GET ACCIDENT ID
                //int order_id = new OrderRepository.OrderRepository(lang).GetOrderIdByUserId(carInfoOrder.carId);

                if (res.status)
                {
                    // Store Video Accident
                    try
                    {
                        var file = Request.Form.Files["video"];

                        // Check if Null So , Do not Store Video
                        if (file == null)
                        {
                            return(res);
                        }


                        var folderName = Path.Combine("Resources", "Images");
                        var pathToSave = @"../dealxImages\videos\orders";//Path.Combine(Directory.GetCurrentDirectory(), folderName);

                        if (file.Length > 0)
                        {
                            var  fileName       = ContentDispositionHeaderValue.Parse(file.ContentDisposition).FileName.Trim('"') + ".mp4";
                            var  fullPath       = Path.Combine(pathToSave, fileName);
                            var  dbPath         = Path.Combine(folderName, fileName);
                            bool UrlVideoStatus = false;
                            using (var stream = new FileStream(fullPath, FileMode.Create))
                            {
                                file.CopyTo(stream);

                                UrlVideoStatus = new OrderRepository.OrderRepository(lang).InsertOrderPictureUrl("videos/orders/" + fileName, 2, Convert.ToInt32(order_id));
                            }
                            if (UrlVideoStatus)
                            {
                                return(res);
                            }
                            else
                            {
                                return(new Response(false, Messages.GetMessage(lang, TypeM.ACCIDENT, orderM.VIDEO_Order_ERROR)));
                            }
                        }
                        else
                        {
                            return(new Response(false, Messages.GetMessage(lang, TypeM.ACCIDENT, orderM.VIDEO_Order_ERROR)));
                        }
                    }
                    catch (Exception ex)
                    {
                        return(new Response(false, Messages.GetMessage(lang, TypeM.ACCIDENT, orderM.VIDEO_Order_ERROR), ex.Message));
                    }
                }
                else
                {
                    return(res);
                }
            }

            else
            {
                return(new Response(false, Messages.GetMessage(lang, TypeM.DEFAULT, defaultM.WRONG_ACCESS_TOKEN)));
            }
        }
Ejemplo n.º 6
0
 public ActionResult <Response> UpdateAccidentData([FromQuery(Name = "lang")] string lang, [FromBody] CarInfoOrder carInfoAccident)
 {
     //check AccessToken
     if (new UserService(lang).CheckAccessToken(carInfoAccident.accessToken))
     {
         return(new OrderService(lang).UpdateAccidentData(carInfoAccident));
     }
     else
     {
         return(new Response(false, Messages.GetMessage(lang, TypeM.DEFAULT, defaultM.WRONG_ACCESS_TOKEN)));
     }
 }
Ejemplo n.º 7
0
 public bool UpdateAccidentData(CarInfoOrder carInfoOrder)
 {
     return(new OrderQuery(language).UpdateAccidentData(carInfoOrder));
 }
Ejemplo n.º 8
0
 public bool InsertOrderData(CarInfoOrder carInfoOrder, string user_id)
 {
     return(new OrderQuery(language).InsertOrderData(carInfoOrder, user_id));
 }