public static DirectionKey GetDirectionFromHAT(HAT hat)
        {
            switch (hat)
            {
            case HAT.TOP:
                return(DirectionKey.Up);

            case HAT.TOP_RIGHT:
                return(DirectionKey.Up | DirectionKey.Right);

            case HAT.RIGHT:
                return(DirectionKey.Right);

            case HAT.BOTTOM_RIGHT:
                return(DirectionKey.Down | DirectionKey.Right);

            case HAT.BOTTOM:
                return(DirectionKey.Down);

            case HAT.BOTTOM_LEFT:
                return(DirectionKey.Down | DirectionKey.Left);

            case HAT.LEFT:
                return(DirectionKey.Left);

            case HAT.TOP_LEFT:
                return(DirectionKey.Up | DirectionKey.Left);

            default:
                return(DirectionKey.None);
            }
        }
            public static Key HAT(HAT hat)
            {
                var name = "HAT." + hat.GetName();

                return(new Key(name,
                               name,
                               r => r.HAT = (byte)hat,
                               r => r.HAT = (byte)NintendoSwitch.HAT.CENTER
                               ));
            }
Example #3
0
        private void InsertServices(string hotelId, string hotelCode, IList <OTA_HotelDescriptiveInfoRS.HotelDescriptiveContentsLocalType.HotelDescriptiveContentLocalType.HotelInfoLocalType.ServicesLocalType> Services)
        {
            if (Check(Services))
            {
                using (var context = new TravelDBContext())
                {
                    //using (TransactionScope tran = new TransactionScope())
                    {
                        EfRepository <HACHATMapping> hachatContext = new EfRepository <HACHATMapping>(context);
                        EfRepository <HAT>           hatContext    = new EfRepository <HAT>(context);
                        EfRepository <HAC>           hacContext    = new EfRepository <HAC>(context);

                        var hachatlist = (from h in hachatContext.Table where h.HotelID == hotelId select h).ToList();

                        if (hachatlist.Count > 0)
                        {
                            hachatContext.Delete(hachatlist);
                            LoggerHelper(hotelCode, "Service Deleted");
                        }


                        foreach (var item in Services[0].Service)
                        {
                            if (string.IsNullOrEmpty(item.Code)) //may be empty
                            {
                                item.Code = "-1";
                            }

                            if (string.IsNullOrEmpty(item.ID)) //may be empty
                            {
                                item.ID = "-1";
                            }

                            int HACID = Convert.ToInt32(item.Code);

                            string descriptiveText = item.DescriptiveText;


                            var hacList = (from h in hacContext.Table where h.Id == HACID select h).ToList();

                            if (hacList.Count == 0)
                            {
                                HAC hac = new HAC();
                                hac.Id   = HACID;
                                hac.Name = descriptiveText;

                                hac.LastModiyTime = DateTime.Now;

                                hacContext.Insert(hac);
                            }

                            int HATID = Convert.ToInt32(item.ID);

                            var hatList = (from h in hatContext.Table where h.Id == HATID select h).ToList();

                            if (hatList.Count == 0)
                            {
                                HAT hac = new HAT();
                                hac.Id   = HATID;
                                hac.Name = "NO";

                                hac.LastModiyTime = DateTime.Now;

                                hatContext.Insert(hac);
                            }



                            HACHATMapping hachatmapping = new HACHATMapping();
                            hachatmapping.HACID           = Convert.ToInt32(HACID);
                            hachatmapping.HATID           = Convert.ToInt32(HATID);
                            hachatmapping.HotelID         = hotelId;
                            hachatmapping.LastModifyTine  = DateTime.Now;
                            hachatmapping.DescriptionText = descriptiveText; //use this value to  display

                            LoggerHelper(hotelCode, "Service,HacID/HATID" + HACID + "/" + HATID + "Inserted");
                            hachatContext.Insert(hachatmapping);
                        }

                        //tran.Complete();
                    }
                }
            }
        }