public HttpResponseMessage UploadFile(CallFileInput input) { var result = new HttpResponseMessage(HttpStatusCode.OK); var call = _callsService.GetCallById(input.Cid); if (call == null) { return(Request.CreateResponse(HttpStatusCode.NotFound)); } if (call.DepartmentId != DepartmentId) { return(Request.CreateResponse(HttpStatusCode.Unauthorized)); } if (call.State != (int)CallStates.Active) { return(Request.CreateResponse(HttpStatusCode.NotAcceptable)); } var callAttachment = new CallAttachment(); callAttachment.CallId = input.Cid; callAttachment.CallAttachmentType = input.Typ; if (String.IsNullOrWhiteSpace(input.Nme)) { callAttachment.FileName = "cameraPhoneUpload.png"; } else { callAttachment.FileName = input.Nme; } callAttachment.UserId = input.Uid; callAttachment.Timestamp = DateTime.UtcNow; callAttachment.Data = Convert.FromBase64String(input.Data); if (!String.IsNullOrWhiteSpace(input.Lat)) { callAttachment.Latitude = decimal.Parse(input.Lat); } if (!String.IsNullOrWhiteSpace(input.Lon)) { callAttachment.Longitude = decimal.Parse(input.Lon); } _callsService.SaveCallAttachment(callAttachment); return(result); }