Ejemplo n.º 1
0
        public IHttpActionResult AddMember(MemberDataViewModel memberView)
        {
            try
            {
                string errorMessage = String.Empty;
                Member member       = new Member();
                if (memberView != null)
                {
                    member.NIC                   = String.IsNullOrEmpty(memberView.nic) ? String.Empty : memberView.nic;
                    member.DOB                   = memberView.dob;
                    member.FullName              = memberView.fullName;
                    member.ShortName             = String.IsNullOrEmpty(memberView.nameWithInitial) ? String.Empty : memberView.nameWithInitial;
                    member.PermanetAddress       = String.IsNullOrEmpty(memberView.permanetAddress) ? String.Empty : memberView.permanetAddress;
                    member.CurrentAddress        = String.IsNullOrEmpty(memberView.currentAddress) ? String.Empty : memberView.currentAddress;
                    member.TrainingCertificateNo = String.IsNullOrEmpty(memberView.cetificateNo) ? String.Empty : memberView.cetificateNo;
                    member.TrainingCenter        = String.IsNullOrEmpty(memberView.trainingCenter) ? String.Empty : memberView.trainingCenter;
                    member.LicenceNo             = String.IsNullOrEmpty(memberView.licenceNo) ? String.Empty : memberView.licenceNo;
                    member.IssuedDate            = memberView.dateIssued;
                    member.ExpireDate            = memberView.dateValidity;
                    member.JoinDate              = memberView.dateJoin;
                    member.HighestEducation      = String.IsNullOrEmpty(memberView.educationQuali) ? String.Empty : memberView.educationQuali;
                    member.TypeId                = memberView.typeId;
                    member.NTCNo                 = _common.GetLastNTCNO(memberView.typeId);
                    member.ImagePath             = memberView.imagePath;
                    _member.Add(member, out errorMessage);
                }
                else
                {
                    errorMessage = Constant.MessageGeneralError;
                }

                var messageData = new
                {
                    code = String.IsNullOrEmpty(errorMessage) ? Constant.SuccessMessageCode : Constant.ErrorMessageCode
                    ,
                    message = String.IsNullOrEmpty(errorMessage) ? Constant.MessageSuccess : errorMessage
                };
                var returnObject = new { ntcNo = member.NTCNo, messageCode = messageData };
                return(Ok(returnObject));
            }
            catch (Exception ex)
            {
                string errorLogId   = _eventLog.WriteLogs(User.Identity.Name, ex, MethodBase.GetCurrentMethod().Name);
                var    messageData  = new { code = Constant.ErrorMessageCode, message = String.Format(Constant.MessageTaskmateError, errorLogId) };
                var    returnObject = new { messageCode = messageData };
                return(Ok(returnObject));
            }
        }