public UpdatedStatus Update(T updatedEntity)
        {
            UpdatedStatus operationStatus = UpdatedStatus.Failed;

            try
            {
                helpDeskContext _db = new helpDeskContext();
                T currentEntity     = _db.Set <T>().FirstOrDefault(ent => ent.Id == updatedEntity.Id);
                _db.Entry(currentEntity).OriginalValues["Timer"] = updatedEntity.Timer;
                _db.Entry(currentEntity).CurrentValues.SetValues(updatedEntity);

                if (_db.SaveChanges() == 1) //shoudl throw if stale;
                {
                    operationStatus = UpdatedStatus.Ok;
                }
            }
            catch (DbUpdateConcurrencyException dbx)
            {
                operationStatus = UpdatedStatus.Stale;
                Console.WriteLine("Problem in " + MethodBase.GetCurrentMethod().Name + dbx.Message);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Problem in " + MethodBase.GetCurrentMethod().Name + ex.Message);
            }
            return(operationStatus);
        }
        public int Update()
        {
            UpdatedStatus osStatus = UpdatedStatus.Failed;

            try
            {
                Calls call = new Calls();
                call.Id         = Id;
                call.EmployeeId = EmployeeId;
                call.ProblemId  = ProblemId;
                call.TechId     = TechId;
                call.DateOpened = DateOpened;
                call.DateClosed = DateClosed;
                call.OpenStatus = OpenStatus;
                call.Notes      = Notes;
                call.Timer      = Convert.FromBase64String(Timer);
                osStatus        = _model.Update(call);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Problem in " + GetType().Name + " " +
                                  MethodBase.GetCurrentMethod().Name + " " + ex.Message);
                throw ex;
            }
            return(Convert.ToInt16(osStatus));
        }
        public int Update()
        {
            UpdatedStatus osStatus = UpdatedStatus.Failed;

            try
            {
                Employees emp = new Employees();
                emp.Title        = Title;
                emp.FirstName    = Firstname;
                emp.LastName     = Lastname;
                emp.PhoneNo      = Phoneno;
                emp.Email        = Email;
                emp.Id           = Id;
                emp.DepartmentId = DepartmentId;
                emp.IsTech       = IsTech;
                if (StaffPicture64 != null)
                {
                    emp.StaffPicture = Convert.FromBase64String(StaffPicture64);
                }
                emp.Timer = Convert.FromBase64String(Timer);
                osStatus  = _model.Update(emp);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Problem in " + GetType().Name + " " +
                                  MethodBase.GetCurrentMethod().Name + " " + ex.Message);
                throw ex;
            }
            return(Convert.ToInt16(osStatus));
        }
示例#4
0
        /// <summary>
        /// コンストラクタ
        /// </summary>
        public Player(IClientMessageTransceiver messageTransceiver)
        {
            this.messageTransceiver = messageTransceiver;

            EventHandler <ReceivedPlayerIdArgs> receivedPlayerIdHandler = (sender, args) =>
            {
                id = args.PlayerId;
            };

            this.messageTransceiver.ReceivedPlayerId += receivedPlayerIdHandler;

            EventHandler <ReceivedStatusArgs> receivedStatusHandler = (sender, args) =>
            {
                publicStatus  = args.PublicStatus;
                privateStatus = args.PrivateStatus;
                UpdatedStatus?.Invoke(this, new UpdatedStatusArgs(publicStatus, privateStatus));
            };

            this.messageTransceiver.ReceivedStatus += receivedStatusHandler;

            EventHandler <ReceivedEndMessageArgs> receivedEndMessageHandler = (sender, args) =>
            {
                switch (args.EndMessage)
                {
                case EndMessage.NotEnd:
                    break;

                case EndMessage.EndRound:
                    EndedRound?.Invoke(this, new EndedRoundArgs());
                    break;

                case EndMessage.EndGame:
                    EndedGame?.Invoke(this, new EndedGameArgs());
                    break;
                }
            };

            this.messageTransceiver.ReceivedEndMessage += receivedEndMessageHandler;
        }
示例#5
0
 private void UpdatedStatusHandler(object sender, EventArgs <Guid, string, UpdateType> e)
 {
     UpdatedStatus?.Invoke(sender, new EventArgs <Guid, string, UpdateType>(e.Argument1, e.Argument2, e.Argument3));
 }