示例#1
0
        internal async Task <ResponseModel> SaveScreening(ScreenedProcess source, int loginId)
        {
            ResponseModel response = new ResponseModel();

            using (IDbConnection conn = _dbConnection.Connection)
            {
                if (source.questions != null && source.questions.Count > 0)
                {
                    List <XElement>   toAdd = new List <XElement>();
                    DynamicParameters param = new DynamicParameters();

                    param.Add("@JobId", source.jobid, DbType.Int32);
                    param.Add("@FirstName", source.firstname.Trim(), DbType.String);
                    param.Add("@LastName", source.lastname.Trim(), DbType.String);
                    param.Add("@CurrentLocation", source.currentlocation.Trim(), DbType.String);
                    param.Add("@Email", source.email.Trim(), DbType.String);
                    param.Add("@Phone", source.phone.Trim(), DbType.String);
                    param.Add("@StartTime", source.starttime, DbType.DateTime);
                    param.Add("@EndTime", source.endtime, DbType.DateTime);

                    if (source.isterminated)
                    {
                        param.Add("@EndReason", source.endreason.Trim(), DbType.String);
                        param.Add("@IsTerminated", source.isterminated, DbType.Boolean);
                    }

                    param.Add("@LoginUserId", loginId, DbType.Int32);

                    source.questions.ForEach((x) =>
                    {
                        toAdd.Add(new XElement("Question", new XAttribute("SequenceOrder", toAdd.Count + 1)
                                               , new XAttribute("ScreenQuestionId", x.questionid)
                                               , new XAttribute("Response", x.option ?? string.Empty)
                                               , new XAttribute("IsNA", x.optionna)));
                    });

                    if (toAdd.Count() > 0)
                    {
                        var add = new XElement("Questions", toAdd);

                        param.Add("@XMLQuestions", add.ToString(), DbType.String);

                        var data = await conn.QueryAsync <int>(Constants.StoredProcedure.MANAGESCREENPROCESS, param, null, null, CommandType.StoredProcedure);

                        int result = 0;

                        if (data.ToList().Count > 0)
                        {
                            result = data.ToList()[0];
                        }

                        response.ResultStatus   = result;
                        response.SuccessMessage = result <= 0 ? string.Empty : "Screening Process Question(s) saved successfully.";
                        response.ErrorMessage   = result <= 0 ? "Error occurred while saving screening process question(s).  Please try again." : string.Empty;
                        return(response);
                    }
                }
            }

            return(response);
        }
示例#2
0
        public async Task <HttpResponseMessage> SaveScreening(ScreenedProcess source)
        {
            ResponseModel result = await VisaDal.Instance.SaveScreening(source, source.loginid);

            return(sendResult(result));
        }