Exemple #1
0
        public static async Task <HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequestMessage req, TraceWriter log, ExecutionContext context)
        {
            try
            {
                // Get request body
                dynamic data = await req.Content.ReadAsAsync <object>();

                string userIdentifier = req.Headers.Authorization.Parameter.ToString();
                // Set name to query string or body data
                var    date = data?.selDate;
                string notificationMsgBody = data?.notificationMsgBody;

                DateTime selDate = DateTime.Parse(date.ToString());
                Helpers.HelperMethods helperMethods = new Helpers.HelperMethods(context);
                bool isSave = await helperMethods.GetTimeTrackerDataService(userIdentifier).MyTeamsSubmitHours(selDate, notificationMsgBody);

                return(isSave == false?req.CreateResponse(HttpStatusCode.BadRequest, "Please pass selected date in the request body")
                           : req.CreateResponse(HttpStatusCode.OK, isSave));
            }
            catch (Exception ex)
            {
                string message = ex.InnerException != null?ex.InnerException.ToString() : ex.Message;

                log.Info(message + " occurred in Submit Team Hours : " + DateTime.Now);
                return(req.CreateResponse(HttpStatusCode.BadRequest, "Error Occured.Please check log Details"));
            }
        }
        public static async Task <HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequestMessage req, TraceWriter log, ExecutionContext context)
        {
            try
            {
                dynamic data = await req.Content.ReadAsAsync <object>();

                DateTime selDt               = data.selDate;
                string   identifier          = data.objIdentifier;
                string   reason              = data.reason;
                string   ID                  = data.id;
                string   date                = data.date;
                string   notificationMsgBody = data.notificationMsgBody;

                // Get request body
                string userIdentifier = req.Headers.Authorization.Parameter.ToString();

                Helpers.HelperMethods helperMethods = new Helpers.HelperMethods(context);
                bool isSuccess = await helperMethods.GetTimeTrackerDataService(userIdentifier).MyTeamWorkHoursRevisionRequest(selDt, identifier, reason, ID, date, notificationMsgBody);

                // Set name to query string or body data

                return(isSuccess == null
                    ? req.CreateResponse(HttpStatusCode.BadRequest, "Please pass a name on the query string or in the request body")
                    : req.CreateResponse(HttpStatusCode.OK, isSuccess));
            }
            catch (Exception ex)
            {
                string message = ex.InnerException != null?ex.InnerException.ToString() : ex.Message;

                log.Info(message + " occurred in HoursRevisionRequest : " + DateTime.Now);
                return(req.CreateResponse(HttpStatusCode.BadRequest, "Error Occurred.Please check log details"));
            }
        }
Exemple #3
0
        public static async Task <HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequestMessage Request, TraceWriter log, ExecutionContext context)
        {
            try
            {
                string userIdentifier = Request.Headers.Authorization.Parameter.ToString();
                // Get request body
                dynamic requestData = await Request.Content.ReadAsAsync <object>();

                string notificationMsgBody          = requestData.notificationMsgBody;
                Helpers.HelperMethods helperMethods = new Helpers.HelperMethods(context);
                var isSave = await helperMethods.GetTimeTrackerDataService(userIdentifier).SubmitHoursForMonthAsync(notificationMsgBody);

                return(isSave == null
                    ? Request.CreateResponse(System.Net.HttpStatusCode.BadRequest, "Please pass a name on the query string or in the request body")
                    : Request.CreateResponse(HttpStatusCode.OK, isSave));
            }
            catch (Exception ex)
            {
                string message = ex.InnerException != null?ex.InnerException.ToString() : ex.Message;

                log.Info(message + " occurred in SubmitHours : " + DateTime.Now);
                return(Request.CreateResponse(HttpStatusCode.BadRequest, "Error Occured.Please check log Details"));
            }
        }