Ejemplo n.º 1
0
        public async Task <bool> ChangeWork(NewWrite mutableWork)
        {
            try
            {
                #region _
                //var tempWork = dataContext.ComplitedWorks.Where(x => x.Id == mutableWork.Id).FirstOrDefault();

                //foreach (var t in tempWork.GetType().GetProperties())
                //{
                //    foreach (var m in mutableWork.GetType().GetProperties())
                //    {
                //        if (t.Name == m.Name)
                //        {
                //            t.SetValue(tempWork, m.GetValue(mutableWork));

                //            continue;
                //        }
                //    }
                //}
                #endregion

                dataContext.ComplitedWorks.Update(mutableWork);

                await dataContext.SaveChangesAsync();

                return(true);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.InnerException.Message);
                return(false);
            }
        }
Ejemplo n.º 2
0
        public async Task RunAddNewWork(NewWrite newWork)
        {
            var result = toSql.AddWork(newWork);

            result.Wait();

            if (result.Result)
            {
                await Clients.All.SendAsync("UpdateWorks", newWork);
            }
            else
            {
                await Clients.Caller.SendAsync("AddedError", result.Result);
            }
        }
Ejemplo n.º 3
0
        public async Task StartChangeWork(NewWrite mutableWork)
        {
            var result = toSql.ChangeWork(mutableWork);

            result.Wait();

            if (result.Result)
            {
                await Clients.All.SendAsync("ChangedWork", mutableWork);
            }
            else
            {
                await Clients.Caller.SendAsync("ChangedError", result.Result);
            }
        }
Ejemplo n.º 4
0
        public async Task <bool> AddWork(NewWrite newWork)
        {
            try
            {
                dataContext.ComplitedWorks.Add(newWork);

                await dataContext.SaveChangesAsync();

                return(true);
            }
            catch
            {
                return(false);
            }
        }