Example #1
0
        public async Task <IActionResult> Update(int id, [FromBody] CallViewModel callModel)
        {
            if (ModelState.IsValid)
            {
                Call _call = _callRepository.GetSingle(id);

                _call.CallStatus = callModel.CallStatus;
                _call.Note       = callModel.Note;
                _call.Time       = DateTime.Now;
                _call.UserName   = callModel.UserName;
                _call.CustomerId = callModel.CustomerId;
                _call.CampaignId = callModel.CampaignId;


                _callRepository.Update(_call);
                if (await _callRepository.Commit())
                {
                    return(new NoContentResult());
                }
            }
            return(BadRequest("Failed To Update Call"));
        }
Example #2
0
        public async Task <ICommandResult> Handle(EditCallCommand command)
        {
            Call call = await _CallRepository.GetById(command.Id);

            if (call == null)
            {
                return(new CommandResult(false, Messages.Account_NOT_FOUND, null));
            }

            NameOrDescription title = new NameOrDescription(command.Name);

            call.Update(
                command.CallTypeId,
                command.CallGroupId,
                command.SectorId,
                command.ContractId,
                command.CustomerId,
                command.EmployeeId,
                command.Priority,
                title,
                command.Details,
                command.UpdatedByUserId
                );

            AddNotifications(title.Notifications);
            AddNotifications(call.Notifications);

            if (!Valid)
            {
                return(new CommandResult(
                           false,
                           Messages.NOTIFICATIONS,
                           Notifications));
            }

            await _CallRepository.Update(call);

            return(new CommandResult(
                       true,
                       Messages.UPDATED_WITH_SUCCESS,
                       new CallCommandResult
            {
                Id = call.Id,
                CallTypeId = call.CallTypeId,
                CallGroupId = call.CallGroupId,
                CustomerId = call.CustomerId,
                SectorId = call.SectorId,
                ContractId = call.ContractId,
                EmployeeId = call.EmployeeId,
                Priority = call.Priority,
                Title = call.Title.Name,
                Details = call.Details,
                Status = call.Status,
                CreatedDate = call.Audit.CreatedDateBy.CreatedDate,
                CreatedByUserId = call.Audit.CreatedDateBy.CreatedByUserId,
                UpdatedDate = call.Audit.UpdatedDateBy.UpdatedDate,
                UpdatedByUserId = call.Audit.UpdatedDateBy.UpdatedByUserId,
                CompanyId = call.Audit.CompanyAndBranchOffice.CompanyId,
                BranchOfficeId = call.Audit.CompanyAndBranchOffice.BranchOfficeId,
                MachineNameOrIP = call.Audit.MachineNameOrIP
            }));
        }