Exemplo n.º 1
0
        //return "Record Not Found.";

        public string GetEmployeeDetails(string name)
        {
            int index = _List.FindIndex(a => a.Name == name);

            try
            {
                if (index != -1)
                {
                    return("ID:" + _List[index].Id + "\n" + "Name:" + _List[index].Name + "\n" + "Remark:" + _List[index].remark + "\n" + "Date:" + _List[index].date + "\n");
                }
                else
                {
                    throw new Exception();
                }
            }
            catch (Exception ex)
            {
                ExceptionFaultContract _faultcontract = new ExceptionFaultContract();
                _faultcontract.StatusCode  = "Empty Database";
                _faultcontract.Message     = "Requested Name is Not Present in the Database";
                _faultcontract.Description = "Error occurred in service";
                throw new FaultException <ExceptionFaultContract>(_faultcontract, new FaultReason(_faultcontract.Message));
            }
            //return "Record Not Found.";
        }
Exemplo n.º 2
0
        public string GetEmployeeDetails(int id)
        {
            int index = _List.FindIndex(a => a.Id == id);

            if (index != -1)
            {
                return("ID:" + _List[index].Id + "\n" + "Name:" + _List[index].Name + "\n" + "Remark:" + _List[index].remark + "\n" + "Date:" + _List[index].date + "\n");
            }
            else
            {
                ExceptionFaultContract _faultcontract = new ExceptionFaultContract();
                _faultcontract.StatusCode  = "Empty Database";
                _faultcontract.Message     = "Requested ID is Not Present in the Database";
                _faultcontract.Description = "Error occurred in service";
                throw new FaultException <ExceptionFaultContract>(_faultcontract, new FaultReason(_faultcontract.Message));
            }
        }
Exemplo n.º 3
0
        public string AddRemarksToEmployee(int id, string remark)
        {
            int index = _List.FindIndex(a => a.Id == id);

            if (index != -1)
            {
                _List[index].remark = remark;
                return("Remark Added Successfully.");
            }
            else
            {
                ExceptionFaultContract _faultcontract = new ExceptionFaultContract();
                _faultcontract.StatusCode  = "Empty Database";
                _faultcontract.Message     = "Requested ID is Not Present in the Database";
                _faultcontract.Description = "Error occurred in service";
                throw new FaultException <ExceptionFaultContract>(_faultcontract, new FaultReason(_faultcontract.Message));
            }
            //return "Record not Found.";
        }