Beispiel #1
0
        public ActionResult <string> Put(string id, [FromBody] ChildDataViewModel model)
        {
            ChildData currentChildData = _context.ChildData.Where(c => c.Id == id).FirstOrDefault();

            if (currentChildData != null)
            {
                currentChildData.FirstName  = model.FirstName;
                currentChildData.LastName   = model.LastName;
                currentChildData.Street     = model.Street;
                currentChildData.City       = model.City;
                currentChildData.Province   = model.Province;
                currentChildData.PostalCode = model.PostalCode;
                currentChildData.Country    = model.Country;
                currentChildData.Latitude   = model.Latitude;
                currentChildData.Longitude  = model.Longitude;
                currentChildData.IsNaughty  = model.IsNaughty;
                currentChildData.BirthDate  = new DateTime(model.BirthYear, model.BirthMonth, model.BirthDay);
                _context.Update(currentChildData);
                _context.SaveChanges();
                Success msg = new Success();
                msg.SetSuccessEdit();
                return(JsonConvert.SerializeObject(msg));
            }
            var errorMsg = new Error();

            errorMsg.UnableToEdit();
            return(JsonConvert.SerializeObject(errorMsg));
        }
        /// <exception cref="System.IO.IOException"/>
        private void ProcessTokenAddOrUpdate(ChildData data)
        {
            ByteArrayInputStream bin   = new ByteArrayInputStream(data.GetData());
            DataInputStream      din   = new DataInputStream(bin);
            TokenIdent           ident = CreateIdentifier();

            ident.ReadFields(din);
            long renewDate = din.ReadLong();
            int  pwdLen    = din.ReadInt();

            byte[] password = new byte[pwdLen];
            int    numRead  = din.Read(password, 0, pwdLen);

            if (numRead > -1)
            {
                AbstractDelegationTokenSecretManager.DelegationTokenInformation tokenInfo = new AbstractDelegationTokenSecretManager.DelegationTokenInformation
                                                                                                (renewDate, password);
                lock (this)
                {
                    currentTokens[ident] = tokenInfo;
                    // The cancel task might be waiting
                    Runtime.NotifyAll(this);
                }
            }
        }
        public async Task <ActionResult> InsertUser([FromBody] RegisterViewModel model)
        {
            try
            {
                Guid newGuid = Guid.NewGuid();
                var  user    = new IdentityUser
                {
                    Email         = model.Email,
                    UserName      = model.Username,
                    SecurityStamp = newGuid.ToString(),
                };
                var result = await _userManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    await _userManager.AddToRoleAsync(user, "Child");
                }

                ChildData currentChild = getChildData(model, user.Id, newGuid);
                _context.Add(currentChild);
                await _context.SaveChangesAsync();

                return(Ok(new { Username = user.UserName, response = true }));
            } catch (Exception e)
            {
                return(Ok(new { Error = e.Message, response = false }));
            }
        }
Beispiel #4
0
        public ActionResult <string> submitEditChild([FromBody] EditChildViewModel model)
        {
            ChildData currentChild = _context.ChildData.Where(c => c.Id.Equals(model.Uid)).FirstOrDefault();

            if (currentChild == null)
            {
                return(Ok(new { response = "Error no child data to edit" }));
            }

            currentChild.FirstName  = model.Firstname;
            currentChild.LastName   = model.Lastname;
            currentChild.Street     = model.Street;
            currentChild.City       = model.City;
            currentChild.Province   = model.Province;
            currentChild.PostalCode = model.PostalCode;
            currentChild.Country    = model.Country;
            currentChild.Latitude   = model.Latitude;
            currentChild.Longitude  = model.Longitude;
            DateTime newBirth = new DateTime(model.BirthYear, model.BirthMonth, model.BirthDay);

            Debug.WriteLine("wowdude" + model.BirthYear);
            currentChild.BirthDate = newBirth;
            _context.ChildData.Update(currentChild);
            _context.SaveChanges();
            return(Ok(new { response = "Successfully Updated Child Data" }));
        }
Beispiel #5
0
 public ActionResult <string> addChildData(string id, [FromBody] AddChildDataViewModel model)
 {
     try
     {
         ChildData newChildData = new ChildData();
         newChildData.FirstName  = model.FirstName;
         newChildData.LastName   = model.LastName;
         newChildData.Street     = model.Street;
         newChildData.City       = model.City;
         newChildData.Province   = model.Province;
         newChildData.PostalCode = model.PostalCode;
         newChildData.Country    = model.Country;
         newChildData.Latitude   = model.Latitude;
         newChildData.Longitude  = model.Longitude;
         DateTime birthday = new DateTime(model.BirthYear, model.BirthMonth, model.BirthDay);
         newChildData.BirthDate = birthday;
         newChildData.Id        = id;
         _context.ChildData.Add(newChildData);
         _context.SaveChanges();
         return(Ok(new { response = "successfully added new child data" }));
     } catch (Exception e)
     {
         return(Ok(new { response = "Error " + e.Message }));
     }
 }
Beispiel #6
0
        public async Task <ActionResult <string> > getEditChildAsync(string id)
        {
            ChildData currentChildData = _context.ChildData.Where(c => c.Id.Equals(id)).FirstOrDefault();

            if (currentChildData == null)
            {
                Error newError = new Error();
                newError.UnableToEditChilData();
                return(Ok(new { response = newError.Message }));
            }
            IdentityUser currentUser = await _userManager.FindByIdAsync(id);

            EditChild currentEditChild = new EditChild();

            if (currentUser != null)
            {
                currentEditChild.Email    = currentUser.Email;
                currentEditChild.UID      = currentUser.Id;
                currentEditChild.Username = currentUser.UserName;
            }
            currentEditChild.myChildData = currentChildData;
            currentEditChild.BirthDay    = currentChildData.BirthDate.Day;
            currentEditChild.BirthMonth  = currentChildData.BirthDate.Month;
            currentEditChild.BirthYear   = currentChildData.BirthDate.Year;
            return(JsonConvert.SerializeObject(currentEditChild));
        }
Beispiel #7
0
        /// <summary>
        /// Create New Child
        /// </summary>
        public Boolean InsertChild(ChildData childData)
        {
            var child = new Child
            {
                LicenseId = childData.LicenseId,
                Name      = childData.Name,
                Avatar    = childData.Avatar,
                Obs       = childData.Obs,
                Category  = childData.Category,
                Created   = DateTime.UtcNow,
                Updated   = DateTime.UtcNow,
                Version   = "1.0"
            };

            using (var context = new CustomerInfoRepository())
            {
                context.Childrens.Add(child);
                try
                {
                    context.SaveChanges();
                    return(true);
                }
                catch (Exception)
                {
                    return(false);
                }
            }
        }
 public void Setup()
 {
     _data       = new ChildData();
     _sourceData =
         new SourceData <ChildData>(Substitute.For <ISource>(), Option <int> .None,
                                    Substitute.For <IItemIdentifier>(), _data);
 }
Beispiel #9
0
 public ActionResult <string> Post([FromBody] ChildDataViewModel model)
 {
     try
     {
         ChildData newChild = new ChildData();
         newChild.Id         = model.Id;
         newChild.FirstName  = model.FirstName;
         newChild.LastName   = model.LastName;
         newChild.Street     = model.Street;
         newChild.City       = model.City;
         newChild.Province   = model.Province;
         newChild.PostalCode = model.PostalCode;
         newChild.Country    = model.Country;
         newChild.Latitude   = model.Latitude;
         newChild.Longitude  = model.Longitude;
         newChild.IsNaughty  = model.IsNaughty;
         newChild.BirthDate  = new DateTime(model.BirthYear, model.BirthMonth, model.BirthDay);
         newChild.DateTime   = DateTime.Now;
         newChild.CreatedBy  = Guid.NewGuid();
         _context.ChildData.Add(newChild);
         _context.SaveChanges();
         var successMsg = new Success();
         successMsg.SetSuccessAdd();
         return(JsonConvert.SerializeObject(successMsg));
     }
     catch (Exception e)
     {
         Error msg = new Error();
         msg.UnableToAdd();
         return(JsonConvert.SerializeObject(msg + " " + e.Message));
     }
 }
Beispiel #10
0
        private void RenderChild(ChildData data)
        {
            if (data.child.Key != null)
            {
                _childPositions.Add(data.child.Key, data.cornerPosition);
            }

            _nextChildren.Add(data);
        }
Beispiel #11
0
        Guid Enqueue(Guid callee, ChildData cd, object prms)
        {
            Guid             caller = cd.Parent;
            WorkflowInstance c      = this.Runtime.GetWorkflow(caller);
            IComparable      qn     = cd.QueueName;

            c.EnqueueItem(qn, prms, null, null);
            _childWorkflows.Remove(callee);

            return(caller);
        }
 public override void Awake()
 {
     base.Awake();
     childDatas = new ChildData[lineCount];
     for (int i = 0; i < lineCount; i++)
     {
         Transform child = transform.GetChild(i);
         childDatas[i] = new ChildData(child);
     }
     // Main.Logger.Log("WarehouseItem Awake " + childDatas.Length);
 }
Beispiel #13
0
        public ActionResult <string> editNaughty(string id, [FromBody] EditNaughtyViewModel model)
        {
            ChildData currentChild = _context.ChildData.Where(c => c.Id.Equals(id)).FirstOrDefault();

            if (currentChild != null)
            {
                currentChild.IsNaughty = model.IsNaughty;
                _context.ChildData.Update(currentChild);
                _context.SaveChanges();
                return(Ok(new { response = "Successfully updated naughty status " }));
            }
            return(Ok(new { response = "Failed to update naughty status" }));
        }
        public void InsertChildTest()
        {
            var repository = new CustomerRepositoryHelper();
            var childData  = new ChildData
            {
                LicenseId = "1234",
                Name      = "Roman",
                Avatar    = "eagle",
                Obs       = "",
                Category  = "category"
            };

            Console.WriteLine(repository.InsertChild(childData));
        }
 private ChildData SetChildData(ChildData currentChildData, EditUserSettingView model)
 {
     currentChildData.Id         = model.Id;
     currentChildData.City       = model.City;
     currentChildData.Country    = model.Country;
     currentChildData.FirstName  = model.FirstName;
     currentChildData.LastName   = model.LastName;
     currentChildData.Latitude   = model.Latitude;
     currentChildData.Longitude  = model.Longitude;
     currentChildData.PostalCode = model.PostalCode;
     currentChildData.Province   = model.Province;
     currentChildData.Street     = model.Street;
     return(currentChildData);
 }
        /// <exception cref="System.IO.IOException"/>
        private void ProcessTokenRemoved(ChildData data)
        {
            ByteArrayInputStream bin   = new ByteArrayInputStream(data.GetData());
            DataInputStream      din   = new DataInputStream(bin);
            TokenIdent           ident = CreateIdentifier();

            ident.ReadFields(din);
            lock (this)
            {
                Collections.Remove(currentTokens, ident);
                // The cancel task might be waiting
                Runtime.NotifyAll(this);
            }
        }
        public void UpdateChild()
        {
            var repository = new CustomerRepositoryHelper();
            var childData  = new ChildData
            {
                Id        = 1,
                LicenseId = "12345",
                Name      = "Sergei1",
                Avatar    = "oak1",
                Obs       = "1",
                Category  = "category1"
            };

            Console.WriteLine(repository.UpdateChild(childData));
        }
 /// <summary>
 /// Method called by MobileFormatter when an object
 /// should serialize its child references. The data should be
 /// serialized into the SerializationInfo parameter.
 /// </summary>
 /// <param name="info">
 /// Object to contain the serialized data.
 /// </param>
 /// <param name="formatter">
 /// Reference to the formatter performing the serialization.
 /// </param>
 public void GetChildren(SerializationInfo info, MobileFormatter formatter)
 {
     foreach (string key in _children.Keys)
     {
         ChildData         value = _children[key];
         SerializationInfo si    = formatter.SerializeObject(value);
         info.AddChild(key, si.ReferenceId);
     }
     foreach (string key in _values.Keys)
     {
         FieldData         value = _values[key];
         SerializationInfo si    = formatter.SerializeObject(value);
         info.AddChild(key, si.ReferenceId);
     }
 }
Beispiel #19
0
        public async Task <ActionResult <string> > GetAsync(string id)
        {
            var user = await _userManager.FindByIdAsync(id);

            ChildData userChildData = _context.ChildData.Where(c => c.Id == id).FirstOrDefault();

            if (userChildData != null)
            {
                UserData currentUserData = new UserData(user, userChildData);
                return(JsonConvert.SerializeObject(currentUserData));
            }
            var error = new Error();

            error.UserDoesNotExist();
            return(JsonConvert.SerializeObject(error));
        }
Beispiel #20
0
        public ActionResult <string> Delete(string id)
        {
            ChildData currentChild = _context.ChildData.Where(c => c.Id == id).FirstOrDefault();

            if (currentChild != null)
            {
                _context.ChildData.Remove(currentChild);
                _context.SaveChanges();
                var successmsg = new Success();
                successmsg.SetSuccessDel();
                return(JsonConvert.SerializeObject(successmsg));
            }
            var msg = new Error();

            msg.UnableToDel();
            return(JsonConvert.SerializeObject(msg));
        }
    void LazyInit()
    {
        childData = new List <ChildData>(transform.childCount);

        for (int i = 0; i < this.transform.childCount; ++i)
        {
            var rect = transform.GetChild(i).GetComponent <RectTransform>();
            if (rect == null)
            {
                continue;
            }

            ChildData child = new ChildData();
            child.childRect        = rect;
            child.onScreenPosition = rect.anchoredPosition;

            childData.Add(child);
        }
    }
Beispiel #22
0
        private ExtraChild CopyToModelExtraChild(ChildData currentChildData)
        {
            ExtraChild currentExtraChild = new ExtraChild();

            currentExtraChild.Id         = currentChildData.Id;
            currentExtraChild.FirstName  = currentChildData.FirstName;
            currentExtraChild.LastName   = currentChildData.LastName;
            currentExtraChild.BirthDate  = currentChildData.BirthDate;
            currentExtraChild.Street     = currentChildData.Street;
            currentExtraChild.City       = currentChildData.City;
            currentExtraChild.Province   = currentChildData.Province;
            currentExtraChild.PostalCode = currentChildData.PostalCode;
            currentExtraChild.Country    = currentChildData.Country;
            currentExtraChild.Latitude   = currentChildData.Latitude;
            currentExtraChild.Longitude  = currentChildData.Longitude;
            currentExtraChild.IsNaughty  = currentChildData.IsNaughty;
            currentExtraChild.DateTime   = currentChildData.DateTime;
            currentExtraChild.CreatedBy  = currentChildData.CreatedBy;
            return(currentExtraChild);
        }
Beispiel #23
0
        private static Uri GetThumbnailFromPreview(ChildData data)
        {
            var absoluteUri = data?.Preview?
                              .Images
                              .FirstOrDefault()?
                              .Resolutions
                              .OrderByDescending(r => r.Height * r.Width)
                              .FirstOrDefault()?
                              .Url
                              .AbsoluteUri;

            if (absoluteUri == null)
            {
                return(null);
            }

            var decoded = HttpUtility.HtmlDecode(absoluteUri);

            return(new Uri(decoded));
        }
Beispiel #24
0
        /// <summary>
        /// Update New Child
        /// </summary>
        public object UpdateChild(ChildData childData)
        {
            using (var context = new CustomerInfoRepository())
            {
                var updating = context.Childrens.FirstOrDefault(x => x.Id == childData.Id);
                if (updating != null)
                {
                    updating.Updated = DateTime.UtcNow;
                    if (childData.Name != null)
                    {
                        updating.Name = childData.Name;
                    }
                    if (childData.Avatar != null)
                    {
                        updating.Avatar = childData.Avatar;
                    }
                    if (childData.Obs != null)
                    {
                        updating.Obs = childData.Obs;
                    }
                    if (childData.Category != null)
                    {
                        updating.Category = childData.Category;
                    }

                    try
                    {
                        context.SaveChanges();
                        return(updating);
                    }
                    catch (Exception)
                    {
                        return(null);
                    }
                }
                else
                {
                    return(null);
                }
            }
        }
Beispiel #25
0
        public void RemoveeCache()
        {
            var watch = Stopwatch.StartNew();
            var cache = new ShareCacheStruct <ChildData>();
            int key   = (int)cache.GetNextNo();
            var data  = cache.FindKey(key);

            if (data == null)
            {
                data = new ChildData()
                {
                    ChildId = key, Age = 20
                };
                Assert.IsTrue(cache.Add(data), "add cache faild.");
            }
            Assert.IsTrue(cache.Delete(data), "delete cache faild");
            cache.UnLoad();
            data = cache.FindKey(key);
            Assert.IsTrue(data == null, "delete cache faild.");
            WaitEnd(watch);
        }
        private ChildData getChildData(RegisterViewModel model, string userid, Guid newGuid)
        {
            ChildData currentChildData = new ChildData();

            currentChildData.FirstName  = model.FirstName;
            currentChildData.LastName   = model.LastName;
            currentChildData.Street     = model.Street;
            currentChildData.City       = model.City;
            currentChildData.Province   = model.Province;
            currentChildData.PostalCode = model.PostalCode;
            currentChildData.Country    = model.Country;
            currentChildData.Latitude   = model.Latitude;
            currentChildData.Longitude  = model.Longitude;
            Debug.WriteLine(model.FirstName);
            currentChildData.BirthDate = new DateTime(model.BirthYear, model.BirthMonth, model.BirthDay);
            currentChildData.DateTime  = DateTime.Now;
            currentChildData.IsNaughty = DEFAULT_NAUGHTY;
            currentChildData.Id        = userid;
            currentChildData.CreatedBy = newGuid;
            return(currentChildData);
        }
Beispiel #27
0
        /// <summary> Calcualate layout after a position or size change. </summary>
        /// <remarks> This method is defined at XrwRectObj for compatibility, but must be implemented for composite widgets only. </remarks>
        public void CalculateChildLayout()
        {
            TPoint childPosition = new TPoint(_borderWidth, _borderWidth);
            TSize  requestedSize = new TSize(0, 0);

            List <ChildData> childData = new List <ChildData>();

            for (int counter = 0; counter < _children.Count; counter++)
            {
                TSize preferredSize = _children[counter].PreferredSize();
                childData.Add(new ChildData(_children[counter], preferredSize));

                if (requestedSize.Width < preferredSize.Width)
                {
                    requestedSize.Width = preferredSize.Width;
                }
                requestedSize.Height += preferredSize.Height;
                if (counter > 0)
                {
                    requestedSize.Height += _vertSpacing;
                }
            }
            requestedSize.Width  = Math.Max(MIN_WIDTH, requestedSize.Width);
            requestedSize.Height = Math.Max(MIN_HEIGHT, requestedSize.Height);

            for (int counter = 0; counter < childData.Count; counter++)
            {
                ChildData cd = childData[counter];

                cd.Widget._assignedPosition.X = childPosition.X;
                cd.Widget._assignedPosition.Y = childPosition.Y;

                cd.Widget._assignedSize.Width  = requestedSize.Width;
                cd.Widget._assignedSize.Height = cd.Size.Height;

                childPosition.Y = childPosition.Y + cd.Size.Height + _vertSpacing;
            }
            this._assignedSize.Width  = requestedSize.Width + 2 * _borderWidth;
            this._assignedSize.Height = requestedSize.Height + 2 * _borderWidth;
        }
Beispiel #28
0
 private static RedditSearchResult MapToSearchResult(ChildData data)
 {
     return(new RedditSearchResult
     {
         Id = data.Id,
         Title = FormatText(data.Title),
         SelfText = FormatText(data.SelfText),
         Url = data.Url,
         Domain = FormatText(data.Domain),
         Score = data.Score,
         Flair = FormatText(data.LinkFlairText),
         CreatedAt = UnixTimeStampToDateTime(data.Created),
         Author = data.Author,
         Subreddit = data.Subreddit,
         PostUrl = new Uri(RedditBaseAddress + data.Permalink),
         Thumbnail = GetThumbnailFromPreview(data),
         IsOver18 = data.Over18,
         IsSelfPost = data.IsSelf,
         IsSpoiler = data.Spoiler,
         IsVideo = data.IsVideo
     });
 }
Beispiel #29
0
        public void UpdateCache()
        {
            var cache = new ShareCacheStruct <ChildData>();
            var data  = cache.FindKey(1);

            if (data == null)
            {
                data = new ChildData()
                {
                    ChildId = 1, Age = 20
                };
                Assert.IsTrue(cache.Add(data), "add cache faild.");
            }
            int age = data.Age;

            age++;
            data.Age = age;
            cache.Add(data);
            Assert.IsFalse(data.HasChanged);
            cache.UnLoad();
            data = cache.FindKey(1);
            Assert.IsTrue(data != null && data.Age == age, "update data fail.");
        }
        /// <summary> Calcualate layout after a position or size change. </summary>
        /// <remarks> This method is defined at XrwRectObj for compatibility, but must be implemented for composite widgets only. </remarks>
        public void CalculateChildLayout()
        {
            TPoint           childPosition         = new TPoint(_borderWidth, _borderWidth);
            List <ChildData> childData             = new List <ChildData>();
            TSize            childrenPreferredSize = new TSize(0, 0);

            for (int counter = 0; counter < _children.Count; counter++)
            {
                TSize preferredSize = _children[counter].PreferredSize();
                childData.Add(new ChildData(_children[counter], preferredSize));

                if (childrenPreferredSize.Width < preferredSize.Width)
                {
                    childrenPreferredSize.Width = preferredSize.Width;
                }
                if (childrenPreferredSize.Height < preferredSize.Height)
                {
                    childrenPreferredSize.Height = preferredSize.Height;
                }
            }

            for (int counter = 0; counter < childData.Count; counter++)
            {
                ChildData cd = childData[counter];

                if (cd.Widget.ExpandToAvailableWidth == true)
                {
                    cd.Size.Width = childrenPreferredSize.Width;
                }
                if (cd.Widget.ExpandToAvailableHeight == true)
                {
                    cd.Size.Height = childrenPreferredSize.Height;
                }

                GeometryManagerAccess.SetAssignedGeometry(cd.Widget, childPosition, cd.Size);
            }
        }