示例#1
0
        public void Update(Guardian guardian)
        {

            using (CosmosContext ctx = new CosmosContext())
            {
                Guardian attachedEnttiy = ctx.Guardians.Find(guardian.Id);

                if (attachedEnttiy != null)
                {
                    try
                    {
                        attachedEnttiy.Address = guardian.Address;
                        attachedEnttiy.Email = guardian.Email;
                        attachedEnttiy.GuardianNo = guardian.GuardianNo;
                        attachedEnttiy.Name = guardian.Name;
                        attachedEnttiy.Relation = guardian.Relation;

                        var attachedEntry = ctx.Entry(attachedEnttiy);
                        attachedEntry.CurrentValues.SetValues(attachedEnttiy);
                        ctx.SaveChanges();
                    }
                    catch (Exception ex)
                    {

                        throw;
                    }
                   
                }
            }

        }
示例#2
0
        public bool UpdateFingerCode(int stdId, byte[] fingerData)
        {

            using (CosmosContext ctx = new CosmosContext())
            {
                try
                {
                    var attachedEntity = ctx.Students.Find(stdId);

                    if (attachedEntity != null)
                    {
                        attachedEntity.FingerCode = fingerData;
                        var attachedEntry = ctx.Entry(attachedEntity);
                        attachedEntry.CurrentValues.SetValues(attachedEntity);
                        ctx.SaveChanges();
                        return true;
                    }
                    return false;
                }
                catch (Exception ex)
                {
                    return false;
                }
            }

        }